jQuery的.按属性名称删除元素.如何? [英] JQuery. Remove element by attribute name. How?
本文介绍了jQuery的.按属性名称删除元素.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以根据其自定义属性comment_id删除DIV?
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>
推荐答案
是的,可能
http://api.jquery.com/category/selectors/
http://api.jquery.com/jQuery.each/
$('div[comment_id="value"]').remove();
这篇关于jQuery的.按属性名称删除元素.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文