Wednesday 8 November 2017

javascript - How to select a button and delete a grandparent div of that button when the button is clicked?

itemprop="text">


This here is my
code.



 $(document).ready(function(){

$(".btn.btn-default.btn-lg.remove").click(function(){

$(this).parent().remove();
});

});







class="col-md-2">

class="col-md-2">

class="col-md-2">

class="col-md-3">









I want
the entire div to get deleted when the button of class="btn btn-default btn-lg remove"
gets clicked. I cant use id because i am dynamically appending the above div using
append jquery.


itemprop="text">
class="normal">Answer



You can
use rel="noreferrer">closest



$(document).ready(function(){

$(".btn.btn-default.btn-lg.remove").click(function(){


$(this).closest('.row').remove();

});
});


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...