wordpress鼠标点击随机数字上升效果

点击站点空白部分,随机生成数字上升效果,或者可以数字++的上升

实现:在主题根目录下面的文件footer.php里面的body里面添加如下代码就行,当然是我自己写的,不太好,还请见谅。

<script type="text/javascript">
/* 鼠标特效 */
var a_idx = 0;
jQuery(document).ready(function($) {
   $("body").click(function(e) {
       //var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善");
      // var $i = $("<span/>").text(a[a_idx]);
	  var n=Math.round(Math.random()*100);//随机数
      var $i=$("<b>").text("+"+(n));
       //a_idx = (a_idx + 1) % a.length;
       var x = e.pageX,
       y = e.pageY;
       
	   if(n%10==0)
	   {
		   $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#ff6651"
       });
	   }
	   else if(n%10==1)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#4A4AFF"
       });
	   }
	   else if(n%10==2)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#EA7500"
       });
	   }
	   else if(n%10==3)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#613030"
       });
	   }
	   else if(n%10==4)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#FF44FF"
       });
	   }
	   else if(n%10==5)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#6F00D2"
       });
	   }
	   else if(n%10==6)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#BEBEBE"
       });
	   }
	   else if(n%10==6)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#F5FFE8"
       });
	   }
	   else if(n%10==7)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#D8D8EB"
       });
	   }
	   else if(n%10==8)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#E2C2DE"
       });
	   }
	   else if(n%10==9)
	   {
		    $i.css({
           "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
           "top": y - 20,
           "left": x,
           "position": "absolute",
           "font-weight": "bold",
           "color": "#FFFF37"
       });
	   }
	   
       $("body").append($i);
       $i.animate({
           "top": y - 180,
           "opacity": 0
       },
       1500,
       function() {
           $i.remove();
       });
   });
});
    </script>