请老师检查代码
来源:4-9 编程练习
qq_慕仰20210716
2021-10-01 20:58:34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<!-- <style>
input{
}
</style> -->
<script>
window.onload = function () {
var btn = document.getElementById("btn");
btn.onmousedown = function () {
btn.style.color = "red";
};
btn.onmouseup = function () {
btn.style.color = "grey";
};
btn.onmouseleave = function () {
btn.style.color = "grey";
};
};
</script>
</head>
<body>
<input type="button" value="点击改变按钮字体颜色" id="btn" />
</body>
</html>
1回答
好帮手慕星星
2021-10-05
同学你好,代码实现效果可以。
另外不需要添加鼠标松开事件,移出事件即可
祝学习愉快!
相似问题