我需要删除具有 value="123"
的元素。 我知道所有具有不同值的元素都位于 #attached_docs
中,但我不知道如何选择具有 value="123"
的元素。
$('#attached_docs').find ... .remove();
你能帮助我吗?
如果页面源代码中使用value
属性硬编码了数值,那么您可以
$('#attached_docs :input[value="123"]').remove();
或者$('#attached_docs :input').filter(function(){return this.value=='123'}).remove();
$('#attached_docs [value=123]').remove();
$("[id=attached_docs][value=123]")
$('#attached_docs [value="123"]').find ... .remove();
它应该满足您的需求,但是您不能重复使用ID!请记住这一点。
$(selector).filter(function(){return this.value==yourval}).remove();
filter
并在内部返回array_var.includes(this.value)
。 - Gabriele Petrioli