I have an javascript object that contains a select list. I’d like to loop through all options within the select. I’m trying the following:
$(this+' .form-select option').each(function() {
console.log(this);
});
A console.log of this shows that it contains the options but for all the option elements on the page not the options I’ve passed to it.
I get the following error “Uncaught Syntax error, unrecognized expression: [object Object]”
Any help would be great.
Use
.find(), like this:thisis an object so you can’t use it in a string, you can however use it to find other elements relatively. Ifthisis already a jQuery object, just do: