php博客中点击随机弹出文字

发表于 2020-03-21  2.07k 次阅读


本站正在使用中

<script  type="text/javascript">
		 $(document).ready(function(){
		 var a_index = 0;
		 $("body").click(function(e){
		 var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
		 function generateMixed(n) {
		 var res = "";
		 for(var i = 0; i < n ; i ++) {
		 var id = Math.ceil(Math.random()*16);
		 res += chars[id];
		 }
		 return res;
		 }
		 var num = generateMixed(6);
		 var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善");
		 var $i = $("<span/>").text(a[a_index]);
		 a_index = (a_index + 1) % a.length;
		 var x = e.pageX,y = e.pageY;
		 $i.css({
				 "moz-user-select": "none",
				 "ms-user-select": "none",
				 "user-select": "none",
				 "z-index": 99999,
				 "top": y - 20,
				 "left": x,
				 "position": "absolute",
				 "font-weight": "bold",
				 "color": "#" + num
		 });
		 $("body").append($i);
		 $i.animate({"top": y-180,"opacity": 0},1500,function() {
				 $i.remove();
		 });
 });
});
</script>
本站文章基于国际协议BY-NA-SA 4.0协议共享;
如未特殊说明,本站文章皆为原创文章,请规范转载。

3

scanz个人博客