How to find elements with 'value=x'?

这一生的挚爱 提交于 2019-12-17 17:53:00

问题


I need to remove element that have value="123". I know that all elements with different values are located into #attached_docs, but I don't know how to select element with value="123".

$('#attached_docs').find ... .remove();

Can you help me?


回答1:


If the value is hardcoded in the source of the page using the value attribute then you can

$('#attached_docs :input[value="123"]').remove();

If you want to target elements that have a value of 123, which was set by the user or programmatically then use EDIT works both ways ..

or

$('#attached_docs :input').filter(function(){return this.value=='123'}).remove();

demo http://jsfiddle.net/gaby/RcwXh/2/




回答2:


Value exactly equal to 123:

jQuery("#attached_docs[value='123']")

Full reference: http://api.jquery.com/category/selectors/




回答3:


Use the following selector.

$('#attached_docs [value=123]').remove();



回答4:


$('#attached_docs [value="123"]').find ... .remove();

it should do your need however, you cannot duplicate id! remember it




回答5:


The following worked for me:

$("[id=attached_docs][value=123]")


来源:https://stackoverflow.com/questions/6732364/how-to-find-elements-with-value-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!