转:js 鼠标点击页面出现文字
代码(注:需要添加jquery.js)
1 <script type="text/javascript"> 2 var a_idx = 0; 3 jQuery(document).ready(function($) { 4 $("body").click(function(e) { 5 var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善"); 6 var $i = $("<span/>").text(a[a_idx]); 7 a_idx = (a_idx + 1) % a.length; 8 var x = e.pageX, 9 y = e.pageY; 10 $i.css({ 11 "z-index": 999999999999999999999999999999999999999999999999999999999999999999999, 12 "top": y - 20, 13 "left": x, 14 "position": "absolute", 15 "font-weight": "bold", 16 "color": "#ff6651" 17 }); 18 $("body").append($i); 19 $i.animate({ 20 "top": y - 180, 21 "opacity": 0 22 }, 23 1500, 24 function() { 25 $i.remove(); 26 }); 27 }); 28 }); 29 </script>