我如何使按钮,当鼠标在按钮上,文字在按钮上变成红色。当鼠标离开按钮时,按钮文本将使用mouseover和mouseout事件恢复原始颜色。
下面是按钮的事件
enter
发布于 2022-02-07 02:09:14
使用css可以很容易地做到这一点,但是,根据您的问题,您将如何完成这一任务:
<button id="button" onmouseover="mouseOver()" onmouseout="mouseOut()" onclick="test()" >Enter</button>
<script>
function mouseOver() {
document.getElementById("button").style.color = "red";
}
function mouseOut() {
document.getElementById("button").style.color = "black";
}
</script>https://stackoverflow.com/questions/71012753
复制相似问题