1

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.

1 Answer 1

2

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);
});​
Sign up to request clarification or add additional context in comments.

1 Comment

thanks – I should have shown you the full code and you would have been able to see that I had failed to create an HTML element for the delete button. works fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.