jQuery的悬停 [英] jquery un-hover

查看:54
本文介绍了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');
    });
});

这篇关于jQuery的悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆