Anyone who is knowing how to override the below mentioned css by using jQuery ?
.actionButton.single-pet { display: none !important; }
It won't work for this : $('.actionButton.single-pet').show();
display: none; is commonly used with JavaScript to hide and show elements without deleting and recreating them.
cssHooks. Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
important is used to increase the priority of a CSS property. This ignores the overriding properties. In jQuery, you can use the css() method to manipulate style property of the selector but this doesn't allow to set ! important to property.
$('.actionButton.single-pet').attr("style", "display: inline !important");
Sets CSS to display: inline !important;
. display: inline
is the default property for display
. You need !important
again to override the previous !important
.
Note that !important
shouldn't be used often. Read the accepted answer at How to override !important? for more details.
UPDATE: We can't use .css()
here as it does not support !important
. http://bugs.jquery.com/ticket/11173 for more details; appears to be a bug.
$('.actionButton.single-pet').removeClass('single-pet');
Or just:
$('.actionButton.single-pet').addClass('single-pet-shown');
With CSS:
.actionButton.single-pet-shown { display: block !important; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With