I want to fadeOut a specific div that was selected using class.
So my HTML looks like this
<div class="container" id="conversations">
<button class="delete" id="1"></button>
</div>
<div class="container" id="conversations">
<button class="delete" id="2"></button>
</div>
<div class="container" id="conversations">
<button class="delete" id="3"></button>
</div>
So heres the case, if I selected delete button with ID that is equals to 3, how will I fadeout its current div element?
This is my jQuery as of now (not working)
$(document).on('click', '.delete', function(e){
e.preventDefault();
$(this).fadeOut();
});
These are the functions that I tried
$('div.container').fadeOut(1000); // working but remove all divs
$(this).fadeOut(); // not working
jQuery(this).parent('div.container').fadeOut(1000); // not working
$(this).parent("div.container").fadeOut(); // not working
$(this).parent($('div.container')).fadeOut(); // not working
Update:
Solves this issue by re-initializing again its element
var _this = $(this);
I call the $(this).fadeOut() in the success callback of ajax where by callings $(this), you are pointing to the success function.
So by doing this inside the success callback func it is now working:
_this.parent('div.container').fadeOut();