博客园鼠标点击特效

需要申请JS权限,JS权限申请通过之后,将如下代码放入侧边栏,页首,页末,都可以

效果为当鼠标点击的时候飘动自定义的图案,比如,小星星,爱心,还有文本之类的

复制如下代码

<script type="text/javascript">
/* 鼠标特效 */
var a_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("❤Linux❤","❤Shell❤","❤Script❤","❤Mysql❤","❤Apache❤","❤Love❤","❤JavaScript❤","❤","❤Python❤");
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>

 

本文来自:https://www.cnblogs.com/lmyupupblogs/p/10268060.html

posted on 2019-03-30 10:06  状元兜里有糖  阅读(392)  评论(0编辑  收藏  举报

导航