JQ 参数进入表达式

因为jq里面可以写 {“attr”:value},{“attr”:“value”},第一种形式也就可以写参数进去

$(".slider").stop().animate({
                        "left": id * 100
                    }, 1000);
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title> </title>
    <script src="../lib/vue.min.js"></script>
    <script src="../js/jquery.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        #box {
            width: 160px;
            height: 160px;
        }

        .a {
            border: 2px solid red;
        }

        .b {
            background: darkmagenta;
        }

        .c {
            border-radius: 50%;
        }

        .item {
            text-align: center;
            height: 50px;
            line-height: 50px;
            width: 100px;
            float: left;
            font-size: 24px;
            color: darkolivegreen;
            background: darkgray;
            /* border: 1px solid dodgerblue; */
            /* padding: 10px 15px; */
        }

        .item.active {
            /* color: rebeccapurple;
            background: #333; */
        }

        .content {
            width: 300px;
            height: 300px;
            background: darkcyan;
            text-align: center;
            line-height: 300px;
            font-size: 80px;
            color: #fff;
        }

        .outer1,.outer2 {
            width: 300px;
            position: relative;
        }

        .slider {
            position: absolute;
            left: 0;
            top: 0;
            width: 100px;
            height: 50px;
            line-height: 50px;
            background:#29A3F1;
            z-index: 1;
            opacity: 0.5;
        }
        .move_box{
            position: relative;
            width: 300px;
            height: 300px;
            overflow: hidden;
        }
        .move{
            position: absolute;
            width: 900px;
            height: 300px;
        }
        .move li{
            float: left;
            list-style: none;
            text-align: center;
            line-height: 300px;
            background:#29A3F1;
            opacity: 0.5;
            width: 300px;
            height: 300px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="outer2">
            <div class="slider"></div>
            <div class="outer1">
                <div @click="change(0)" class="item" :class="current==0?'active':''" id="btn1">菜单01</div>
                <div @click="change(1)" class="item" :class="current==1?'active':''" id="btn2">菜单02</div>
                <div @click="change(2)" class="item" :class="current==2?'active':''" id="btn3">菜单03</div>
            </div>
            <div class="move_box">
                    <ul class="move">
                            <li>内容01</li>
                            <li>内容02</li>
                            <li>内容03</li>
                    </ul>
            </div>
        </div>



    </div>
    <script>
        // 作业  添加动画 
        const vm = new Vue({
            el: "#app",
            data: {
                title: "class && style 动态绑定 ",
                flagA: true,
                classObj: {
                    b: true,
                    c: true
                },
                isA: 'a',
                isC: 'c',
                id: 1901,
                styleObj: {
                    border: "2px solid green"
                },
                current: 0
            },
            methods: {
                change(id) {
                    console.log(id);
                    this.current = id;
                    $(".slider").stop().animate({
                        "left": id * 100
                    }, 1000);
                    $(".move").stop().animate({
                        "left": id * (-300)
                    }, 1000)
                }
            },
            mounted() {
                document.getElementsByTagName('title')[0].innerHTML = this.title;
            }
        })


    </script>
</body>

</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值