How to find elements with 'value=x'?

JqueryFindAttr

Jquery Problem Overview


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?

Jquery Solutions


Solution 1 - Jquery

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/

Solution 2 - Jquery

Value exactly equal to 123:

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

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

Solution 3 - Jquery

Use the following selector.

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

Solution 4 - Jquery

The following worked for me:

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

Solution 5 - Jquery

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

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

Solution 6 - Jquery

$(selector).filter(function(){return this.value==yourval}).remove();

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondaGrevisView Question on Stackoverflow
Solution 1 - JqueryGabriele PetrioliView Answer on Stackoverflow
Solution 2 - JqueryÁlvaro GonzálezView Answer on Stackoverflow
Solution 3 - JqueryGazlerView Answer on Stackoverflow
Solution 4 - JqueryAriView Answer on Stackoverflow
Solution 5 - JquerygenesisView Answer on Stackoverflow
Solution 6 - JqueryHAmid Alizade Q.View Answer on Stackoverflow