following is my HTML
HTML :
<div Attr1 = "val1" Attr2 = "val2" Attr3 = "val3" >
Hello !!
</div>
I want to extract all the attributes (& its corresponding values
) of an element.
How can I do this using jQuery?
I tried something like below,
$(function() {
for(var i in $('div')[0].attributes) {
console.log($('div')[0].attributes)[i] , $('div')[0].attributes)[i].value);
}
});
Are there any more possible ways for doing this ?
Thank you !