Document
#box {
width: 150px;
height: 150px;
background: black;
color: white;
border: 10px solid #000;
cursor: crosshair;
margin: 0 auto;
}
#box.hover {
color: red;
background: #f0f0f0;
border: 10px solid red;
}
鼠标移入移出改变样式
window.onload = function(){
var div = document.getElementById("box");
div.onmouseover = function(){
div.className = "hover";
}
div.onmouseout = function(){
div.className = "";
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史