JQuery. Remove element by attribute name. How?
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).at开发者_运维问答tr('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>
Yes, possible
http://api.jquery.com/category/selectors/
http://api.jquery.com/jQuery.each/
$('div[comment_id="value"]').remove();
精彩评论