Javascript examples for DOM:Element attributes
Element attributes Property - Find out how many attributes an <img> element have:
<!DOCTYPE html> <html> <body> <img id="myImg" alt="Flower" src="http://java2s.com/resources/a.png" width="150" height="113"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .ja v a2s . com*/ var x = document.getElementById("myImg").attributes.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>