Javascript examples for DOM:Attribute
Attribute length Property - Find out how many attributes an <img> element has
<!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 ww . j a v a 2s .c o m*/ var x = document.getElementById("myImg").attributes.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>