jQuery的hover
作者:dangbao 日期:2009-11-18
我们都知道CSS的规范里有:hover的伪类,就是鼠标经过元素时,可以影响元素外观的样式。大家也都知道,在IE6中,只有在链接上才能看到hover的效果。那么今天介绍的jQuery则可以让我们实现鼠标经过元素触发.hover的样式。在css里写一个.hover{background:#ccc;}的样式,那么,即使鼠标经过没链接的H1时,也会触发.hover的灰色背景。
Code
$(document).ready(function() {
$('h1').hover(function(){
$(this).addClass('hover');
}, function(){
$(this).removeClass('hover');
});
});
$('h1').hover(function(){
$(this).addClass('hover');
}, function(){
$(this).removeClass('hover');
});
});
评论: 1 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

Tags:
文章来自:
网摘收藏:
回复
]