dcochran
dcochran

Reputation: 1105

Remove Dynamic Parent Element in jQuery Mobile

I'm populating a table with PHP code that talks to my database. The PHP echo's code back into the table as separate rows. Each row has a delete button and I want to make that delete button remove the row from the DOM.

echo "<tr><td data-creator='$creator'>{$comment}<a class='deleteComment' 
data-role='button' data-icon='delete' data-iconpos='notext';></a></td></tr>";

// php code ends

<script type='javascript'>

$(".deleteComment").click(function () {
$(this).parent().remove();
});
</script>

This won't work. And when I put a console.log statement into the .deleteComment function, nothing prints to the console when I click on the delete button within a row.

Upvotes: 1

Views: 308

Answers (1)

imwill
imwill

Reputation: 598

I set up a quick example. Works like a charm for me. I don't see any mistake. A more complete example of your code would be good.

Did you try to log like this? What will it show?

$(".deleteComment").click(function (err) {
    console.log(err);
});​

Upvotes: 2

Related Questions