<li style="padding-bottom: 0px; display: none;">
<span> Content </span>
</li>
display == none
if($(this).closest('li').attr('style') =='padding-bottom: 0px; display: none;'){
// script
}
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
}