My html code looks like this...
<div class="container">
<div id="tropical">
<div class="info">
<div class="desc">
<p>Lorem ipsum.......</p>
</div>
<div class="list_of_fruits">
<ul class="list">
<li class="fruit">Avocado</li>
<li class="fruit">Banana</li>
<li class="fruit">Watermelon</li>
</ul>
</div>
</div>
</div>
<div id="sub_tropical">
<div class="info">
<div class="desc">
<p>Lorem ipsum.......</p>
</div>
<div class="list_of_fruits">
<ul class="list">
<li class="fruit">Apple</li>
<li class="fruit">Blackberry</li>
</ul>
</div>
</div>
</div>
</div>
I am trying to get all the parent divs of li
with class "fruit" that are within div
with id=tropical...
I have done this much so far ...
$(".fruit").parents().filter("div");
but it selects parents of <li>
within div with id=sub_tropical
USe
$("#tropical").find(".fruit").parents();
$("#tropical").find(".fruit")
will get the .fruits
containing in #tropical
div
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