Skip to main content
added 357 characters in body
Source Link
Nick Craver
  • 631.4k
  • 138
  • 1.3k
  • 1.2k

It depends how you want to select it, to remove by text:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt1"; }).remove(); 

Or the selected one:

$("select[name=ShippingMethod] option:selected").remove(); 

Or the second one:

$("select[name=ShippingMethod] option:eq(1)").remove(); 

Or the last one:

$("select[name=ShippingMethod] option:last").remove(); 

To just select option 2 by text, you can use the same .filter() approach above:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt2"; }).attr("selected", true); 

You can test it here.

It depends how you want to select it, to remove by text:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt1"; }).remove(); 

Or the selected one:

$("select[name=ShippingMethod] option:selected").remove(); 

Or the second one:

$("select[name=ShippingMethod] option:eq(1)").remove(); 

Or the last one:

$("select[name=ShippingMethod] option:last").remove(); 

It depends how you want to select it, to remove by text:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt1"; }).remove(); 

Or the selected one:

$("select[name=ShippingMethod] option:selected").remove(); 

Or the second one:

$("select[name=ShippingMethod] option:eq(1)").remove(); 

Or the last one:

$("select[name=ShippingMethod] option:last").remove(); 

To just select option 2 by text, you can use the same .filter() approach above:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt2"; }).attr("selected", true); 

You can test it here.

Source Link
Nick Craver
  • 631.4k
  • 138
  • 1.3k
  • 1.2k

It depends how you want to select it, to remove by text:

$("select[name=ShippingMethod] option").filter(function() { return this.text == "Opt1"; }).remove(); 

Or the selected one:

$("select[name=ShippingMethod] option:selected").remove(); 

Or the second one:

$("select[name=ShippingMethod] option:eq(1)").remove(); 

Or the last one:

$("select[name=ShippingMethod] option:last").remove();