js改变鼠标的形状和样式的方法 |
本文标签:鼠标样式,形状 当今多数浏览器支持一下指针样式(将鼠标移动到样式名称上以观察指针样式改变为那个样式): auto move no-drop col-resize all-scroll pointer not-allowed row-resize crosshair progress e-resize ne-resize default text n-resize nw-resize help vertical-text s-resize se-resize inherit wait w-resize sw-resize 在windows internet explorer 6.0或者更新版本,上面的指针样式如下: ![]() 要通过脚本改变某一个元素的鼠标指针样式,你可以把元素的属性element.style.cursor设为上面的任何一个值 。(另外一种不用javascript的方法,可以在元素的html标签中使用属性): 复制代码 代码如下: function setcursorbyid(id,cursorstyle) { if (document.getelementbyid) { if (document.getelementbyid(id).style) { document.getelementbyid(id).style.cursor=cursorstyle; } } } 补充一个常用的改变鼠标样式的方法:如果你想鼠标移动到某个元素上改变鼠标样式 就在这个元素的样式里加上 cursor:(你想改的样式) 。 |