0

I've been looking at this answer https://stackoverflow.com/a/9048545/364088 which presents the following code.

$("select#mySelect option[value='option1']").remove()

That's useful but what can be done if you already have a variable initialized like this .

var mySel = $("select#mySelect");

How would you be able to incorporate that variable into the ".remove" example shown above ?

Something like this (but obviously not this)

mySel.("option[value='option1']").remove()
glaucon
  • 7,508
  • 9
  • 38
  • 59

1 Answers1

1

Use .find to find descendants matching a particular selector:

mySel.find("option[value='option1']").remove()
CertainPerformance
  • 313,535
  • 40
  • 245
  • 254