Is there a way to remove a DIV based on it's custom attribute comment_id?
I have the following code but it does not quite work yet.
<script type="text/javascript">
$('.delete_comment').live('click', function() {
// Url we request data from
$.get( "http://www.site.com/pages/delete/user_comment.php",
// Url parameters to send
{id:$(this).attr('comment_id'),c:'yes'},
// Output data from php file generated by PHP echo.
function(data)
{
var comment_id = $(this).attr('comment_id').val();
//alert(comment_id);
if (comment_id == data) {
$(this).remove();
}
});
});
</script>
To remove an attribute from each tag using jQuery, use the removeAttr() method and use the Universal Selector.
The removeAttr() method removes one or more attributes from the selected elements.
Yes, possible
http://api.jquery.com/category/selectors/
http://api.jquery.com/jQuery.each/
$('div[comment_id="value"]').remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With