JavaScript实现,鼠标放到连接上,连接颜色变化
来源:百度知道 编辑:UC知道 时间:2024/06/04 11:10:54
<style type="text/css">
a{
event:expression(
onmouseover = function()
{
this.style.color='red'
},
onmouseout = function()
{
this.style.color='blue'
}
)
}
</style>
<a href="456.htm" >呵呵,把鼠标放在这里试试看</a>
这样做有什么好处呢?好处就是分离代码,减小耦合度!
这不用JS用css就能搞定,a:hover{}
这种简单的效果用JS不划算,记住什么都有开支。
<a href="xxx.htm" onmouseover="this.style.color='red';" onmouseout="this.style.color='blue'" >Put Mouse On Me!</a>
这用css实现岂不是更好?