用JS抓取每个IMG的ID .鼠标移动到哪张图片上就抓取哪张图片的ID,并显示出鼠标经过的ID,该怎么弄
用JS抓取每个IMG的ID .鼠标移动到哪张图片上就抓取哪张图片的ID,并显示出鼠标经过的ID,该怎么弄
[解决办法]
<div id="dvImgID"></div>
<img id="img1" src="xx.jpg" />
<img id="img2" src="xx.jpg" />
<img id="img3" src="xx.jpg" />
<img id="img4" src="xx.jpg" />
<script>
document.onmousemove = function (e) {
e = e
[解决办法]
window.event;
var o = e.target
[解决办法]
e.srcElement;
if (o.tagName == 'IMG') document.getElementById('dvImgID').innerHTML = o.id;
}
</script>