views:

47

answers:

2

Hi, I using jquery how do i remove the one of the elements of the select dropdown where the value

<option value=" ">undefined</option>

i tried

$("#subType option[value=' ']").remove();
$("#subType option[value='']").remove();

None of them worked.

Please advise.

+2  A: 
 $("#subType option:contains(undefined)").remove();

But note that this will also remove options like:

<option value="foo">undefined bar</option>

You can read about any method in the API documentation. It is divided into categories which makes finding easier, e.g. traversing, manipulation, etc.

Felix Kling
Wow, thanks a lot Felix. what is he best place for me to read/refer documentation on jquery? especially the form elements.
Shah
The jQuery documentation would be the best place, but I also like quick references like this one: http://www.artzstudio.com/2009/04/jquery-performance-rules/#learn-the-library
wsanville
A: 

In case removing options like 'undefined blah blah' is not desired, this will remove the exact text:

$('#subType option').filter(function() {
      return $(this).text() == 'undefined';
  }).remove();
wsanville