用CSS来设置onmouseover和onmouseout事件

五月 23, 2008 by FDS  
类别:DIV+CSS 已经有4,475次浏览

用CSS来设置onmouseover事件实例:

ul{
/*设置onmouseover事件*/
onmouseover: expression(onmouseover=function (){this.style.borderColor =’#cccccc’;this.style.color=’#ffffff’;this.style.backgroundColor =’#0099ff’});

/*设置onmouseout事件*/
onmouseout: expression(onmouseout=function (){this.style.borderColor=”;this.style.color=”;this.style.backgroundColor =”});
background-color:#ffffff;
}

这段代码实现的功能就是当鼠标移动到ul列表时,背景就会变成蓝色,文字变成白色,边框变成灰色.这种效果一般用在当用UL代替表格时,实现的当整行变换效果!