3 回答
TA贡献9条经验 获得超6个赞
js就是用onmouseover和onmouseout事件来操作:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#test{width:100px;height:50px;background:red;color: white;font-size:24px;text-align:center;line-height:50px;}
</style>
</head>
<body>
<div id='test'>js方法</div>
</body>
<script type="text/javascript">
var oDiv=document.getElementById('test');
// 鼠标移入事件
oDiv.onmouseover=function(){
this.style.background='orange';
this.style.color='blue';
};
// 鼠标移出事件
oDiv.onmouseout=function(){
this.style.background='red';
this.style.color='white';
};
</script>
</html>
在事件里面写入你要修改的属性就行!!!
添加回答
举报
