开发者

JQuery. Remove element by attribute name. How?

开发者 https://www.devze.com 2023-04-10 19:24 出处:网络
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.

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号