121

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

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

Can you help me?

Skully
  • 2,882
  • 3
  • 20
  • 31
daGrevis
  • 21,014
  • 37
  • 100
  • 139

6 Answers6

189

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

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

or

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

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

Skully
  • 2,882
  • 3
  • 20
  • 31
Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
23

Value exactly equal to 123:

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

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

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
4

Use the following selector.

$('#attached_docs [value=123]').remove();
Gazler
  • 83,029
  • 18
  • 279
  • 245
3

The following worked for me:

$("[id=attached_docs][value=123]")
Ari
  • 990
  • 12
  • 12
2
$(selector).filter(function(){return this.value==yourval}).remove();
Hamed Alizade
  • 107
  • 1
  • 6
2
$('#attached_docs [value="123"]').find ... .remove();

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

genesis
  • 50,477
  • 20
  • 96
  • 125