jQuery remove selected option from this

故事扮演 提交于 2019-12-03 01:09:59

this isn't a css selector. you can avoid spelling the id of this by passing it as a context:

$('option:selected', this).remove();

http://api.jquery.com/jQuery/

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

Using the find method.

This should do the trick:

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

This is a simpler one

$('#some_select_box').find('option:selected').remove().end();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!