<li style="padding-bottom: 0px; display: none;">
<span> Content </span>
</li>
i want to check display == none
i got the solution with the below script.
if($(this).closest('li').attr('style') =='padding-bottom: 0px; display: none;'){
// script
}
any other simple way to write. Thanks
The issue you have is that you're mixing jQuery and vanilla JS methods here, with .attr().display. You're also trying to compare the whole style string against (if it worked) one CSS rule.
A better method of achieving this would be to use jQuery's is() method, along with the :visible selector. Try this:
if ($(this).closest('li').is(':visible')) {
// script
}
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