没有显示!重要的是需要使用jQuery覆盖

时间:2013-09-13 10:54:38

标签: jquery css

任何知道如何使用jQuery覆盖下面提到的css的人?

 .actionButton.single-pet
        {
            display: none !important;
        }

它不适用于此:$('.actionButton.single-pet').show();

2 个答案:

答案 0 :(得分:55)

$('.actionButton.single-pet').attr("style", "display: inline !important");

将CSS设置为display: inline !important;display: inlinedisplay的默认属性。您需要再次!important覆盖之前的!important

请注意,!important不应经常使用。请阅读How to override !important?上接受的答案,了解详情。

更新:我们无法在此使用.css(),因为它不支持!importanthttp://bugs.jquery.com/ticket/11173了解更多详情;似乎是一个错误。

答案 1 :(得分:2)

$('.actionButton.single-pet').removeClass('single-pet');

或者只是:

$('.actionButton.single-pet').addClass('single-pet-shown');

使用CSS:

.actionButton.single-pet-shown {
    display: block !important;
}