Jo Micheal
27 Jan 2022
jQuery
Hello everyone, I am facing an issue when I try to use CSS function using jQuery to set !important the code I am using is
jQuery("div.shipping_address").css({ "display": 'none !important' });
it adds the display: none; but without the !important What should I do to add it?
Thanks in Advance
Joseph Morgan
27 Jan 2022
Best Answer
Welcome Back Jo,
Css function in jQuery doesn't support !important so the other way to do this is by adding using .attr like this code below
jQuery("div.shipping_address").attr("style", "display: none !important;");
this gonna work with you also you can keep main style of the div by storing the attribute value in element then add it to the code above like
var styleAttr = jQuery("div.shipping_address").attr('style');
jQuery("div.shipping_address").attr("style", styleAttr+"display: none !important;");
Good luck
Jo Micheal
27 Jan 2022
Thank you this is really helpful
© 2024 Copyrights reserved for web-brackets.com