代码

html:

<ul id="list">
                
      <li><img class="smalimg" src="images/xiaotuituji1.png"></li>
      <li><img class="smalimg" src="images/xiaotuituji2.png"></li>
</ul>

 

js:

<script>
     var ul = document.getElementById('list');
    var lis = ul.getElementsByTagName('li');
    for (var i = 0; i < lis.length; i++) {
        lis[i].onmouseover = function() {
            console.log(this.getElementsByTagName('img')[0].attributes[1].nodeValue);
         }
      }
    </script>

 

通过

javascript src属性 js获取src属性_html

 

 

往下找src的值

javascript src属性 js获取src属性_js_02