Using jQuery / Underscore, Given the following list. How can I find all .msg elements that are not within an li w data-allow-html="true"
<ol>
<li><div class="msg">message</div></li>
<li data-allow-html="true"><div class="msg">message</div></li>
<li><div class="msg">message</div></li>
<li data-allow-html="true"><div class="msg">message</div></li>
<li><div class="msg">message</div></li>
<li data-allow-html="true"><div class="msg">message</div></li>
<li><div class="msg">message</div></li>
<li data-allow-html="true"><div class="msg">message</div></li>
</ol>
I currently have:
$('#mydiv').find('.msg').each(function() {}
And have tried:
$('#mydiv').find('li').not('data-allow-html="true"').find('.msg').each(function() {}
Which does not seem to work. Ideas? Thanks
You can use the following to get all the
<li>withing#mydiv, then checking fornot()containing the attribute, then finding each.msg