闲来无事的人,又来水文了
写一段简单的js代码,实现鼠标点击随机提示文字,如本站效果,废话不多说,贴代码
JavaScript
var click_count=0;$(document).click(function(e){ var str=$dianjiwenzi; var text = str.split(","); var color=new Array(//颜色数组 "#C01E22", "#0088cc", "#FF5E52", "#2CDB87", "#00D6AC", "#EA84FF", "#FDAC5F", "#FD77B2", "#0DAAEA", "#C38CFF", "#FF926F", "#8AC78F", "#C7C183", "#9370DB", "#2f889a", "#9e5ae2"); var n=Math.floor(Math.random()*color.length+1)-1; click_count=(click_count+1)%text.length; var $i=$("<span>").text(text[click_count]); var x=e.pageX,y=e.pageY;//鼠标点击坐标 $i.css({ "position":"absolute", "z-index":"10000", "top":y-15, "left":x, "color":color[n], "font-size":"14px", "font-weight":"700" }); $("body").append($i); $i.animate({ "top":y-180,//纵向偏移量 "opacity":"0"},2000,function(){ $i.remove();//移除显示的文字 }); e.stopPropagation();//防止冒泡})});
水文完毕,又骗取一些流量。。。。。^_^
微信扫码查看本文
发表评论