怎么在JavaScript代码中实现连接时出现的小手型

JavaScript011

怎么在JavaScript代码中实现连接时出现的小手型,第1张

用 <a href="...">...</a>做的链接,鼠标默认就是小手型。

除非你在 CSS 中有别的定义。

如果页面有引入 css 文件,可以看 css 文件中

a {

...

}

这样的定义,把以上大括号中关于cusor的定义删除即可。

或者像楼上说的写上 cursor:pointer

要在别的地方显示小手图标也是一样的处理,可以用 css,也可以用 style 属性指定:

style="cursor:pointer

"

window.onload=function(){

document.getElementsByTagName("body").item(0).style.cursor="pointer"

}

如果无效则body不够大,换成:

window.onload=function(){

document.getElementsByTagName("*").item(0).style.cursor="pointer"

}

当然,最好由CSS解决。