js怎么获取图片的相对地址

 

 

<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=gb2312" />
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="小秦" />
  <meta name="keywords" content="小秦" />
  <meta name="description" content="" />
 </head>
 <body>
  <ul id="int">
    <li><img src="images/2.jpg" width="69" height="51"  onmouseover="Change_p(0)"/></li>
  </ul>
  <script type="text/javascript">
  //<![CDATA[
  function Change_p(m) {
    var object = document.getElementById("int").getElementsByTagName("img");
    for (var i = 0; i < object.length; i++) {
      if (i == m) {
        var str = object[i].getAttribute('src', 2);
        window.alert(str);
      }

      return;
    }
  }
  Change_p(0);
  //]]>
  </script>
</body>
</html>

 

posted @ 2015-06-24 17:55  dekevin  阅读(552)  评论(0编辑  收藏  举报