<script type="text/javascript">
function RefreshHint() {
var img_src = document.getElementById('nav_content').getElementsByTagName('img');
for (i=0; i<img_src.length; i++)
alert(img_src.item(i).id);
}
</script>
<html>
<head>
</head>
<body>
    <div class="nav_content_bottom" id="nav_content">
        <div class="pic">
            <img src="jpg/01.jpg" onmouseover="RefreshHint()" id="1" />
        </div>
        <div class="pic">
            <img src="jpg/02.jpg" onmouseover="RefreshHint()" id="2" />
        </div>
    </div>
</body>
</html>当鼠标每个img上移入的时候, 调用RefreshHint, 怎么让函数知道鼠标移入了哪个img ?

解决方案 »

  1.   


    <html>
    <head>
    <script type="text/javascript">
    function RefreshHint(obj) {
       alert(obj.id);
    }
    </script>
    </head>
    <body>
      <div class="nav_content_bottom" id="nav_content">
      <div class="pic">
      <img src="jpg/01.jpg" onmouseover="RefreshHint(this)" id="1" />
      </div>
      <div class="pic">
      <img src="jpg/02.jpg" onmouseover="RefreshHint(this)" id="2" />
      </div>
      </div>
    </body>
    </html>