I have a list and there is a delete button on every LI element. When you click the delete button, delete the LI element with the fade effect.
This is my code below.
<ul data-role="listview" data-inset="true" data-icon="false" class="recentList">
<li>
<a href="#" class="showDetail">
<h2>
<p class="txtName">
Title
</p>
</h2>
</a>
<p class="expand">
Details
</p>
<button class="delete" data-inline="true">Delete</button>
</li>
<li>
<a href="#" class="showDetail">
<h2>
<p class="txtName">
Title
</p>
</h2>
</a>
<p class="expand">
Details
</p>
<button class="delete" data-inline="true">Delete</button>
</li>
</ul>
<script>
$(".recentList").on('click', '.delete', function () {
$(this).fadeOut(300, function(){
$(this).parent().remove();
});
});
</script>
The problem is that when I click the “Delete” button, the LI element does not get the “fade” effect.
How can I fix it?
here is DEMO - http://fiddle.jshell.net/5zDVQ/
source
share