欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript獲取網(wǎng)頁中第一個圖片id的方法

 更新時間:2015年04月03日 11:03:15   作者:瘋狂一夏  
這篇文章主要介紹了JavaScript獲取網(wǎng)頁中第一個圖片id的方法,涉及javascript中document.images方法的使用技巧,需要的朋友可以參考下

本文實例講述了JavaScript獲取網(wǎng)頁中第一個圖片id的方法。分享給大家供大家參考。具體如下:

下面的代碼通過document.images獲取網(wǎng)頁中的所有圖片,然后獲取第一個圖片的id屬性

<!DOCTYPE html>
<html>
<body>
<img id="klematis lilac" border="0" src="klematis.jpg" 
width="148" height="112">
<img id="klematis pink" border="0" src="klematis2.jpg" 
width="149" height="118">
<p>Id of first image:
<script>
document.write(document.images[0].id);
</script></p>
</body>
</html>

運行結(jié)果如下:

Id of first image:klematis lilac

希望本文所述對大家的javascript程序設(shè)計有所幫助。

相關(guān)文章

最新評論