I would like to be able to loop through and log each option available in a select dropdown box. I'm not sure how to do this while using $(this)
.
This is what I have.
$('select').each(function(){
$(this).find('options').each(function(){
var boxOpt = $(this).text();
console.log(boxOpt);
});
});
It currently outputs nothing. I would like to be able to do something like:
$(this + ' options').each(function(){...});
but this is not working either.
I have tried
$(this).find()
, $(this).children()
and some other variations, but I'm not sure what to do now.
Any suggestions? Thank you