码迷,mamicode.com
首页 > Web开发 > 详细

JS淘宝浏览商品

时间:2020-02-21 12:49:34      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:htm   node   div   nts   dde   淘宝   top   one   width   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>相册</title> 
    <style>
        *{
            margin:0;
            padding:0;

        }
        ul{
            list-style: none;
            overflow: hidden;
        }
        ul li{
            float: left;
            width: 55px;
            height: 40px;
            margin-top: 10px;
            margin-left: 10px;
            border: 2px solid #fff;
        }
            ul li.active{
                border-color: red;
            }
    </style>
</head>

<body>
        <img src="img/1.jpeg" id="img">
        <ul>
            <li>
                <a href="">
                    <img src="img/1.jpeg" width="55px" height="40px" class="small">
                </a>

            </li>
            <li>
                <a href="">
                    <img src="img/2.jpeg" width="55px" height="40px"  class="small">
                </a>

            </li>
            <li>
                <a href="">
                    <img src="img/3.jpeg" width="55px" height="40px" class="small">
                </a>

            </li>
            <li>
                <a href="">
                    <img src="img/4.jpeg" width="55px" height="40px"  class="small">
                </a>
          </li>
        </ul>
   <script>
    var big=document.getElementById(‘img‘);
    var small=document.getElementsByClassName(‘small‘);
    for(var i=0;i<small.length;i++)
    {
        small[i].onmouseover=function()
        {
            for(var j=0;j<small.length;j++)
            {
                small[j].parentNode.parentNode.setAttribute(‘class‘,‘‘);
            }
            var smalls=this.getAttribute(‘src‘);
            big.setAttribute(‘src‘,smalls);

            this.parentNode.parentNode.setAttribute(‘class‘,‘active‘);
        }
    }
    </script>
</body>

</html>

JS淘宝浏览商品

标签:htm   node   div   nts   dde   淘宝   top   one   width   

原文地址:https://www.cnblogs.com/lxabner/p/12340928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!