老师麻烦帮我检查一下代码

来源:2-7 编程练习

慕9588112

2019-06-26 20:48:38

<!DOCTYPE html>
<html>

<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
button{margin:20px;}
</style>
</head>

<body>
<button class="btn" onmouseover="mouseoverFn(this,'purple') " onmouseout="mouseoutFn(this,'#ccc')">开始</button>
<button class="btn" onmouseover="mouseoverFn(this,'yellow')" onmouseout="mouseoutFn(this,'#ccc')">结束</button>
<script type="text/javascript">
function mouseoverFn(btn,color){
btn.style.color=color;
}
function mouseoutFn(btn,color){
btn.style.color=color;
}
</script>
</body>

</html>


写回答

2回答

好帮手慕码

2019-06-27

同学你好!

代码效果实现的不错

这个参数btn指的是鼠标移入移出事件里面的参数 this。这个this就是button标签。和class无关

http://img.mukewang.com/climg/5d141dc70001ffce12750234.jpg

如果帮助到了你 欢迎采纳 祝学习愉快~

0

慕9588112

提问者

2019-06-26

function mouseoverFn(btn,color){

btn.style.color=color;

}

还有这里的参数btn指的是上面button里的类名btn是吗?

有点懵,是照着前面课程的代码写的,这里有点搞不清楚了

0

0 学习 · 40143 问题

查看课程