其他分享
首页 > 其他分享> > 仿TheNorthFace官网 购物车效果

仿TheNorthFace官网 购物车效果

作者:互联网

<!DOCTYPE html>
<html>

<head>
    <title>千锋教育——做真实的自己,用心做教育</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: red;
            display: none;
        }
    </style>
</head>

<body>
    <button>点我</button>
    <div></div>
</body>

</html>
<script>

    let oBtn = document.querySelector('button')
    let oDiv = document.querySelector('div')
    let flag = false;
    let f = false;
    oBtn.onmouseover = function () {
        oDiv.style.display = 'block'
    }
    oBtn.onclick = function () {
        oDiv.setAttribute('index', 1)
        if (oDiv.getAttribute('index') == 1) {
            this.onmouseout = null;
        }
        flag = !flag;
        if (flag) {
            oDiv.style.display = 'none'
            flag = true;
        } else {
            oDiv.style.display = 'block'
            falg = false;
        }
    }
    oBtn.onmouseout = function () {
        oDiv.style.display = 'none'

    }
</script>

  

标签:oBtn,style,oDiv,TheNorthFace,购物车,flag,let,官网,display
来源: https://www.cnblogs.com/xiaorain124/p/15541260.html