Reputation: 241
var currentSelect = 'option1';
$('#selectMail option[value=' + currentSelect + ']').remove();
What I am trying to do above is to remove a option from a select where the option value equals currentSelect. This however returns the error
Uncaught Error: Syntax error, unrecognized expression: #selectMail option[[email protected]]
What is happening here?
Upvotes: 0
Views: 54
Reputation: 44814
try
$('#selectMail option[value="' + currentSelect + '"]').remove();
Upvotes: 1
Reputation: 15699
Value of attribute should be wrapped in quotes.
It should be
$('#selectMail option[value="' + currentSelect + '"]').remove();
Upvotes: 1