javascript - output all set attributes of an element -


this question has answer here:

i have jquery object represents input button element on page. how can jquery output via console.log properties/attributes of element?

assuming html of page is

<body>   <img id="smile" class="big" alt="smile" madeupattribute="yep" src="http://mikegrace.s3.amazonaws.com/forums/stack-overflow/smile.png"/> </body> 

you do

var domelement = $("img")[0] // [0] returns first dom element jquery found $(domelement.attributes).each(function(index, attribute) {   console.log("attribute:"+attribute.nodename+" | value:"+attribute.nodevalue); }); 

example page => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-get-element-attributes-jquery.html

example page console output

alt text


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -