Most of the developers might have faced this situation where they need to add !important while using css method in jQuery. Mostly we need to avoid using !important in our CSS style sheets but in some situations we are forced to use the same. For example: when we want to change the font-size of sub elements under a parent element because of some inheritance the font-size might not change, in these scenarios – most of the developers forcefully apply !important as a simple work-around.
If you want to add !important dynamically while using css method, then here is the way to do so.
When we add the above line into your page, it will render like below, assuming that it has been applied to a div of id named ‘addImportant’:
The above snippet has helped me in resolving one of the task which I need to complete, and hope this might help you some situation.
Most Commented Posts
- Bookmark: 50+ stunning jQuery applications
- Snippet Code for Simple Ajax Tabs with cool CSS Styles
- ERROR: Apache service not started [-1], XAMPP SERVER
- Awesome enough Slide Shows developed using jQuery, Ajax, Prototype.js, Ext.js, Lightbox JS, Mootools, YUI
- Floating SlideIn Menu with Anchor Link using jQuery
- Most Useful Firefox add-ons for Web Development
- Simple Bookmark Script using jQuery
- We the Team won in Truveo Developer Challenge Contest – TechVideoBytes