当指针变为指针并将鼠标悬停在框上然后将文本更改为“箭头”时,将标签文本更改为“手动”...这是我的代码
<html>
<style>
#box:hover {
background-color: red;
}
#box {
width: 300px;
height: 300px;
border: 1px solid;
background-color: black;
}
</style>
<body>
<div id="box" onmouseover="myFunction()"></div>
<label id="lab">arrow</label>
</body>
<script>
function myFunction() {
document.getElementById("lab").innerHTML = "hand";
document.getElementById("box").style.cursor = "pointer"
}
</script>
</html>
答案 0 :(得分:2)
您可以将onmouseout
添加到mouseout的触发功能。
#box:hover {
background-color: red;
}
#box {
width: 300px;
height: 300px;
border: 1px solid;
background-color: black;
}
&#13;
<div id="box" onmouseover="myFunction(true)" onmouseout="myFunction(false)"></div>
<label id="lab">arrow</label>
<script>
function myFunction(over) {
if (over) {
document.getElementById("lab").innerHTML = "hand";
document.getElementById("box").style.cursor = "pointer"
} else {
document.getElementById("lab").innerHTML = "arrow";
}
}
</script>
&#13;