How do I copy the attributes of one element to another element?
HTML
A working solution on jsfiddle
EDIT
Updated jsfiddler
Javascript
$(function(){
var destination = $('#adiv').eq(0);
var source = $('#bdiv')[0];
for (i = 0; i < source.attributes.length; i++)
{
var a = source.attributes[i];
destination.attr(a.name, a.value);
}
});
HTML
A class
B class
That's copying #bdiv attributes to #adiv.