Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

traverse element inside the div

html:

<div style="width: 260px;margin:25px 0 0 30px">
<input type="checkbox"  name="send_email" class="delete_followup" />Send email alerts
<input type="checkbox" value="delete" type="checkbox" />Send SMS alerts <button type="submit" name="delete" value="{{follower.id}}" class="delete_follower">Delete</button>
</div>

js:

$(".delete_followup").click(function(){
var $this = $(this);
$(this).find(".delete_follower").show();           
});

I want to show the hidden button on clicking the delete_followup class.i TRIED WITH ABOVE jQuery but not working.

like image 563
user2681579 Avatar asked Feb 12 '26 01:02

user2681579


2 Answers

Or try .nextAll:

$(this).nextAll(".delete_follower").show();

Working here: http://jsfiddle.net/tw5XK/

like image 66
Ivan Chernykh Avatar answered Feb 14 '26 14:02

Ivan Chernykh


The delete_follower element is not a decedent of delete_followup element, it is a sibling element so instead of find() you need to use siblings()

$(".delete_followup").click(function(){
    var $this = $(this);
    $this.siblings(".delete_follower").show();           
});
like image 44
Arun P Johny Avatar answered Feb 14 '26 15:02

Arun P Johny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!