jQuery remove selected option from this

Posted by odavy on Stack Overflow See other posts from Stack Overflow or by odavy
Published on 2010-03-22T17:04:52Z Indexed on 2010/03/22 17:11 UTC
Read the original article Hit count: 280

Filed under:
|
|
|
|

Hi all, first post here, I come in peace :) I've searched but can't quite find what I'm after.

I am trying to manipulate the selected option of a select box. Can someone please explain why this works:

$('#some_select_box').click(function() {
  $('#some_select_box option:selected').remove();
});

but this doesn't:

$('#some_select_box').click(function() {
  $('this option:selected').remove();
});

I just want to use "this" instead of spelling out the id of the select box - can someone point me in the right direction for the correct syntax? It's driving me mad because it looks like it should be really simple. And I'm sure it is to someone, but not me, cos its the end of the day and I'm brain-fried... Any pointers much appreciated.

Cheers

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about select