本文实例讲述了JS获取网页图片name属性的方法。分享给大家供大家参考。具体如下:
下面的JS代码可以用来获取网页图片的name属性
<!DOCTYPE html> <html> <body> <img src="/static/imghw/default1.png" data-src="compman.gif" class="lazy" id="compman" name="compman" alt="Computerman" style="max-width:90%" style="max-width:90%"> <br> <script> document.write("Image name: "); document.write(document.getElementById('compman').name); </script> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。