javascript 获取图片相对应的ID

来源:百度知道 编辑:UC知道 时间:2024/05/11 16:00:01
<div id="img" style="position:absolute; width:100px; height:80px; left:10px; top:5; ">
<img width="100" height="80" id="id1" src="images/_KF[HIA5TB~@SC7[~2U$[KR.jpg" />
</div>

<div id="img1" style="position:absolute; width:100px; height:80px; left:9px; top:89px; ">
<img width="100" height="80" id="id2" src="images/1.jpg" onmouseover="" /></div>

<div id="img2" style="position:absolute; width:100px; height:80px; left:9px; top:171px; ">
<img width="100" height="80" id="id3" src="images/2.jpg" onmouseover="" /> </div>

鼠标放图片上获得它相对应的图片ID?

<div id="img" style="position:absolute; width:100px; height:80px; left:10px; top:5; ">
<img width="100" height="80" id="id1" src="images/_KF[HIA5TB~@SC7[~2U$[KR.jpg" />
</div>

<div id="img1" style="position:absolute; width:100px; height:80px; left:9px; top:89px; ">
<img width="100" height="80" id="id2" src="images/1.jpg" onmouseover="" /></div>

<div id="img2" style="position:absolute; width:100px; height:80px; left:9px; top:171px; ">
<img width="100" height="80" id="id3" src="images/2.jpg" onmouseover=getid(this) /> </div>

<script type="text/javascript">
function getid(obj){
alert(obj.id);
}
</script>

onmouseover=