A jQuery plugin is applying an inline style (display:block). I’m feeling lazy and want to override it with display:none.
What’s the best (lazy) way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update: while the following solution works, there’s a much easier method. See below.
Here’s what I came up with, and I hope this comes in handy – to you or anybody else:
This will remove that inline style.
I’m not sure this is what you wanted. You wanted to override it, which, as pointed out already, is easily done by
$('#element').css('display', 'inline').What I was looking for was a solution to REMOVE the inline style completely.
I need this for a plugin I’m writing where I have to temporarily set some inline CSS values, but want to later remove them; I want the stylesheet to take back control.
I could do it by storing all of its original values and then putting them back inline, but this solution feels much cleaner to me.
Here it is in plugin format:
If you include this plugin in the page before your script, you can then just call
and that should do the trick.
Update: I now realized that all this is futile.
You can simply set it to blank:
and it’ll automatically be removed for you.
Here’s a quote from the docs:
I don’t think jQuery is doing any magic here; it seems the
styleobject does this natively.