本文實例講述了JS獲取網頁圖片name屬性的方法。分享給大家供大家參考。具體如下:
下面的JS代碼可以用來獲取網頁圖片的name屬性
<!DOCTYPE html>
<html>
<body>
<img id="compman" name="compman"
src="compman.gif" alt="Computerman" width="107" height="98">
<br>
<script>
document.write("Image name: ");
document.write(document.getElementById('compman').name);
</script>
</body>
</html>
希望本文所述對大家的javascript程序設計有所幫助。