鼠标点击特效代码

鼠标点击特效代码

 

需要JQuery支持

 

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

 

<script type="text/javascript">
            var a_idx = 0;
            jQuery(document).ready(function($) {
                $("body").click(function(e) {
                    var a = new Array("❀", "❀", "❀", "❀", "❀", "❤", "❤", "❤", "❤", "❤", "❤", "❤", "❀", "❀", "❀",
                        "❀", "❀", "❀", "❀");
                    var $i = $("<span></span>").text(a[a_idx]);
                    a_idx = (a_idx + 1) % a.length;
                    var x = e.pageX,
                        y = e.pageY;
                    $i.css({
                        "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
                        "top": y - 20,
                        "left": x,
                        "position": "absolute",
                        "font-weight": "bold",
                        "color": "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," +
                            ~~(255 * Math.random()) + ")"
                    });
                    $("body").append($i);
                    $i.animate({
                            "top": y - 180,
                            "opacity": 0
                        },
                        1500,
                        function() {
                            $i.remove();
                        });
                });
            });
        </script>

 

posted @ 2022-02-18 19:48  依笑  阅读(301)  评论(0编辑  收藏  举报