I want to apply height
for specific div using jquery but not able to override the '!important'
keyword using jquery
.
Here is markup:
<div id="divL1" class="myclass">sometext here</div> <div id="divL2" class="myclass">sometext here</div> <div id="divL3" class="myclass">sometext here</div> <div id="divL4" class="myclass">sometext here</div>
css:
.myclass{ height:50px !important; }
Here i want to find the class
"myclass" where divid equals "divL3"
I have Tried with:
$('#divL3.myclass').css('height', '0px');
but wont work! so, how to override '!important' css using jquery
.
Help appreciated!
cssHooks. Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
You can do this: $("#elem"). css("cssText", "width: 100px ! important;");
The jQuery CSS methods allow you to manipulate CSS class or style properties of DOM elements. Use the selector to get the reference of an element(s) and then call jQuery css methods to edit it. Important DOM manipulation methods: css(), addClass(), hasClass(), removeClass(), toggleClass() etc.
Try This :
$( '.myclass' ).each(function () { this.style.setProperty( 'height', '0px', 'important' ); });
.setProperty () enables you to pass a third argument which represents the priority.
Another Easy method to solve this issue adding style attribute.
$('.selector').attr('style','width:500px !important');
This will solve your problem easily... :)
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