Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find elements with 'value=x'?

Tags:

jquery

find

attr

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?

like image 699
daGrevis Avatar asked Jul 18 '11 11:07

daGrevis


People also ask

How do you find the element of data value?

Use the querySelector method to get an element by data attribute, e.g. document. querySelector('[data-id="box1"]') . The querySelector method returns the first element that matches the provided selector or null if no element matches the selector in the document.

How do I select a specific Dropdownlist using jQuery?

Syntax of jQuery Select Option$(“selector option: selected”); The jQuery select option is used to display selected content in the option tag. text syntax is below: var variableValue = $(“selector option: selected”).

How get value from data attribute in jQuery?

You can use this jquery data() syntax for get data-id attribute value. $("selector"). data("textval"); You can use this jquery data() syntax for get data-textval attribute value.

How use contains in jQuery?

jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).


1 Answers

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/

like image 75
Gabriele Petrioli Avatar answered Sep 29 '22 17:09

Gabriele Petrioli