How to get the parents siblings content Jquery -
below, code. goal is, when user clicks <a>
tag in 'siblings_2'. want alert 'hello' in 'sibling_1' content. how can achieve this?
<div class="parent"> <div class="sibling_1"> <div class="selections"> <p>hello</p> <p>how you?</p> </div> </div> <div class="sibling_2"> <a href="">click me!</a> </div> </div>
you have various ways achieve , 1 way is:
$("div.sibling_2 a").click(function(e) { e.preventdefault(); var text = $(this).parent().prev().find("div.selections p:eq(0)").text(); alert(text); })
Comments
Post a Comment