我们举例为鼠标移入test标签时变色(为显示效果添加一条黑色边框):
测试文档 我是测试
CSS伪元素的写法为
a:hover{background:blue;}
JQ写法为(效果与hover一样)
$(function(){
$('.test').mouseover(function(){
$(this).css({'background':'blue'});
}).mouseout(function(){
$(this).css({'background':''});
});
});
JS写法不多加赘述,与JQ用法类似,同样是需要写一个移入移出事件