jqurey实现点赞特效

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style >
        .container{
            padding: 50px;
            border:  1px solid #dddddd;
        }
        .item{
            position: relative;
            width:30px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item"><span >赞</span>
        </div>
    </div>
    <div class="container">
        <div class="item"><span >赞</span></div>
    </div>
     <div class="container">
        <div class="item"><span >赞</span></div>
    </div>
    <div class="container">
        <div class="item"><span >赞</span></div>
    </div>

    <script src="jquery1.9.js"></script>
    <script>
        $(".item").click(function () {
           // console.log(11);
            AddFavor(this);
        })
        function AddFavor(self) {
            var fontsize=3;
            var top=0;
            var right=0;
            var opcity=1;

            var tag=document.createElement('span');
            $(tag).text("+1");
            $(tag).css("color","green");
            $(tag).css("position","absolute");
            $(tag).css("fontSize",fontsize+"px");
            $(tag).css("right",right+"px");
            $(tag).css("top",top+"px");
            $(tag).css("opacity",opcity);
            $(self).append(tag);
            var obj=setInterval(function () {
                fontsize=fontsize+5;
                top=top-10;
                right=right-10;
                opcity =opcity-0.1;
                $(tag).css("color","green");
                $(tag).css("position","absolute");
                $(tag).css("fontSize",fontsize+"px");

                 console.log(fontsize);
                $(tag).css("right",right+"px");
                $(tag).css("top",top+"px");
                $(tag).css("opacity",opcity);
                if(opcity<0){
                    clearInterval(obj);
                    $(tag).remove();
                }
            },40);
        }

    </script>
</body>
</html>

注意大小写

转载于:https://www.cnblogs.com/bianzhuo/p/9938731.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值