Reputation: 261
I have a jquery scripts aimed at deleting the parent div. However, the delete button doesn't appear as a button and won't delete the parent div. I am using jQuery Mobile.
Here is the jquery:
$(".delete_content").click(function() {
$(this).closest(".content_container").remove();
});
Here is the html:
<div class='content_container'>
<a class='delete_content' data-role='button' data-icon='delete' data-inline='true' data-iconpos='right'>
Delete
</a>
</div>
Upvotes: 0
Views: 61
Reputation: 146310
$(".delete_content").click(function() {
$(this).parents(".content_container").remove();
});
You need to use .parents
and not .closest
Upvotes: 3