108

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?

HenricF
  • 219
  • 1
  • 18
daGrevis
  • 19,600
  • 35
  • 95
  • 134

6 Answers6

171

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/

Gabriele Petrioli
  • 173,972
  • 30
  • 239
  • 291
19

Value exactly equal to 123:

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

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

Álvaro González
  • 128,942
  • 37
  • 233
  • 325
4

Use the following selector.

$('#attached_docs [value=123]').remove();
Gazler
  • 78,438
  • 15
  • 263
  • 235
2

The following worked for me:

$("[id=attached_docs][value=123]")
Ari
  • 900
  • 11
  • 11
2
$('#attached_docs [value="123"]').find ... .remove();

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

genesis
  • 48,512
  • 18
  • 91
  • 118
0
$(selector).filter(function(){return this.value==yourval}).remove();