移动鼠标挂件
<head> <style> img{ position: absolute; width: 50px; height: 50px; } </style> </head> <body> <img src="img.jpg" alt=""> <script> let img = document.getElementsByTagName("img") document.addEventListener("mousemove", function (ad){ img[0].style.left = ad.pageX-25+"px" img[0].style.top = ad.pageY-25+"px" }) </script> </body>
字符串去除空格
<script> let string = "我是孔某父亲 " console.log(string) //去除首尾空格 trim() string = string.trim() console.log(string) //去除所有空格 replace() string = string.replace("","") console.log(string) </script>
jQuery动画
jQuery提供了一些默认的动画 控制元素的显示和隐藏 show() hide() 语法:$("selector").show([speed],[callback]); 参数描述: 参数一:速度,可选 例如:1000毫秒等等于1秒 fast slow normal 参数二:回调函数,可选 hide函数执行完之后,要执行的函数 控制元素的透明度 findIn() findOut() 控制元素的高度 slideUp() slidedown()