js怎么实现鼠标经过变抓手

JavaScript010

js怎么实现鼠标经过变抓手,第1张

亲,给要经过鼠标变手型的元素加onmouseover事件的处理函数,设置该元素的style.cursor="pointer"就可以了,离开的时候也就是onmouseout的事件处理函数里面加style.cursor=""就可以了

window.onload=function(){

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

}

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

window.onload=function(){

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

}

当然,最好由CSS解决。