下面的HTML和CSS能够实现div的隔行变色:
<head>
<style>
#container div{
width:200px;
height:25px;
font-size:14px;
text-align:center;
color:#474747;
}
.even{
background-color: #EDEDED;
}
.odd{
background-color: #FAFAFA;
}
</style>
</head>
<body>
<div id="container">
<div class="even">1</div>
<div class="odd">2</div>
</div>
</body>
如果要实现效果:鼠标移到某一行上,改变背景和文字颜色;鼠标移除,还原以前的背景和文字颜色。
JQuery代码可以实现这个效果:
$("#container div").hover(function(){
// 鼠标经过时,改变背景色和文字颜色
$(this).css("backgroundColor","#346ba3");
$(this).css("color","rgb(255,2