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
  • 8,112
  • 9
  • 41
  • 63

1 Answers1

1

Use .find to find descendants matching a particular selector:

mySel.find("option[value='option1']").remove()
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320