Reputation: 4408
I have a problem with element selection, i have a form and i want to run each
function for each form select
box, here is my code:
$("#profile_form select").each(function(i){
var seen = {};
$(this + 'option').each(function() {
var txt = $(this).text();
if (seen[txt])
$(this).remove();
else
seen[txt] = true;
});
});
Now my problem is with $(this + 'option')
part, if i try to select only select menu it works fine, but i need to select option
and if i do that i get:
Uncaught Error: Syntax error, unrecognized expression: [object HTMLSelectElement]option
what am i doing wrong?
Upvotes: 0
Views: 2037
Reputation: 263147
$(this + "option")
tries to add a string to a DOM element, which is probably not what you want. You might be looking for:
$(this).find("option")
Or, alternatively:
$("option", this)
Upvotes: 2