[英]how to select only div within parent after click
我試圖找出如何在單擊事件之后在其父div中選擇具有特定類名的特定元素。
<div id="news">
<div class="one">
<p>news</p>
</div>
<div class="two">
<a href="#" class="clickme"></a>
</div>
</div>
<div id="users">
<div class="one">
<p>users</p>
</div>
<div class="two">
<a href="#" class="clickme"></a>
</div>
</div>
我簡單的jQuery如下所示:
$(".clickme").on("click", function () {
//how to select only the element with the class "one" within the parent and show it
});
我嘗試失敗的嘗試是嘗試使用父級和最接近的方法以及類似$(this).parents().find(".one").show();
任何幫助將是巨大的!
嘗試這個
$(this).parent()
引用parent
div
.prev('one')
到類.one
上一個同級
$(this).parent().prev(".one").show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.