How do I copy the attributes of one element to another element?
HTML
You can use the native Node#attributes property: http://jsfiddle.net/SDWHN/16/.
var $select = $("select"); var $div = $("div"); var attributes = $select.prop("attributes"); // loop through attributes and apply them on $.each(attributes, function() { $div.attr(this.name, this.value); }); alert($div.data("foo")); 0 讨论(0) 查看其它11个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复