用js 实现光棒效果和隔行换色
<script type="text/javascript">
$(function () {
//获取所有的tr
var str = $(document.getElementsByTagName("tr"));
for (var i = 1; i < str.length; i++) {
str[i].onmouseover = function over() {
this.style.background = "#87D3D8";
}
str[i].onmouseout = function out() {
this.style.background = "";
}
}
for (i = 1; i < str.length; i++) {
(i % 2 == 0) ? (str[i].className = "color_td1") : (str[i].className = "color_td2");
}
})
</script> <style type="text/css">
.color_td1 { BACKGROUND-COLOR: red; TEXT-ALIGN: center }
.color_td2 {BACKGROUND-COLOR:Blue; TEXT-ALIGN: center }
</style>
浙公网安备 33010602011771号