OK, I have some code that looks like this, and I want to target only the headings which are inside a container, but not inside another container inside of it (if that makes sense). Currently it catches them all. How do I change that? I know about the “not” selector, but I’m not sure how to tell jQuery “target headings inside haccordion, but not if they are inside something inside of that”.
<script>
(document).ready(function(){
$(".haccordion :header").css("background-color","yellow");
});
</script>
<div class="haccordion">
<h2>Target this</h2>
<p class="section">Here is some text content</p>
<h3>Target this</h3>
<div class="section">
<p>Here is some content with text and an image</p>
<h3>Don't target this</h3>
<p>Here is some more text</p>
</div>
<h3>Target this</h3>
<section>
<h4>Don't target this</h4>
<ul>
<li>List item 1</li>
<li>List item 2</li>
</ul>
</section>
</div>