JQuery select class inside parent class
I am trying to select a class inside the same parent link class.
This is html:
<div id="productList"> <ul> <li class="productListItem"> Product 1 <span class="smallText">stuff</span> <div class="skuFinder"></div> <ul class="merchantsInProductList"> <li><a class="merchantLink" href="/Pricing/SkuFinder/1/1">Merchant 1 $5.99</a></li> </ul> </li> </ul> </div> When the "merchantLink" class is clicked, I would like to load jQuery into the "skuFinder" class
What is the best way to select the skuFinder class?
$("a.merchantLink").click(function(){ // (if div is the previous element to ul) $(this).closest("ul.merchantsInProductList").prev("div.skuFinder"); // (if div is the not previous element to ul and is anywhere inside li with //class productListItem) $(this).closest("li.productListItem").find("div.skuFinder"); });