admin管理员组

文章数量:1414934

I have created a jQuery widget for other people to embed on their website, and within the widget I am using a css reset stylesheet called "cleanslate" from here:

This stops the page style creeping into my widget.

Problem is that my fadeOut and fadeIn's are no longer working because the reset style is overriding the display inline style jQuery is adding. I need to make the fadeOut function add !important; to the inline style.

Does anyone know if this is possible?

Thanks in advance.

I have created a jQuery widget for other people to embed on their website, and within the widget I am using a css reset stylesheet called "cleanslate" from here:

https://github./premasagar/cleanslate

This stops the page style creeping into my widget.

Problem is that my fadeOut and fadeIn's are no longer working because the reset style is overriding the display inline style jQuery is adding. I need to make the fadeOut function add !important; to the inline style.

Does anyone know if this is possible?

Thanks in advance.

Share Improve this question asked Oct 17, 2013 at 10:42 superphonicsuperphonic 8,0846 gold badges34 silver badges64 bronze badges 6
  • The !important is pertaining to CSS. You cannot apply it to jQuery. Can you paste your code – MarsOne Commented Oct 17, 2013 at 10:43
  • look here: stackoverflow./questions/2655925/… hope that helped. – geevee Commented Oct 17, 2013 at 10:44
  • @MarsOne I want jQuery to add !important to the display: style it adds to the element when I use $('#element').fadeOut('slow'); <-- all that does is add display: none, and drop the opacity. I need it to add display: none !important... – superphonic Commented Oct 17, 2013 at 10:53
  • Can you paste your code? – MarsOne Commented Oct 17, 2013 at 10:54
  • I just did... $('#element').fadeOut('slow'); #element is a <div> – superphonic Commented Oct 17, 2013 at 10:55
 |  Show 1 more ment

1 Answer 1

Reset to default 7

I came up with the solution below, hope it helps someone else in the same situation.

All ments / improvements wele:

    jQuery("element").fadeOut("slow", function() {
        jQuery("element").attr("style", "display: none !important");
    });

Thanks

本文标签: javascriptjQueryMaking fadeOUt use importantStack Overflow