jQuery的悬停
问题描述:
我有这个脚本在段落中的链接悬停时在段落上引起背景色.我不知道该怎么做,是因为一旦我悬停",它就会恢复为原始背景色.
I have this script to cause a background color on a paragraph on hover of link within the paragraph. What I don't know how to do is cause it to return to the original background color once I "un-hover".
$(function(){
$(".box a").hover(function(){
$(this).parent().css('background-color', '#fff200');
});
});
谢谢!
答
下面的函数用作onmouseover和onmouseout
The function below works as onmouseover and onmouseout
$(function(){
$(".box a").hover(function(){
$(this).parent().css('background-color', '#fff200');
}, function(){
// change to any color that was previously used.
$(this).parent().css('background-color', '#fff200');
});
});