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>
在事件里面寫入你要修改的屬性就行?。?!
添加回答
舉報