Reputation: 264
in the code below, I need to know what choice is being selected. What is the appropriate way? Thank you
$(window).ready(function() {
$("#Tmimata > option").each(function(index) {
var mythis = $(this);
if (mythis.selected) {
}
else {
}
});
});
Upvotes: 0
Views: 220
Reputation: 12290
To check if the element is selected, you should use .prop()
:
if (mythis.prop('selected')) {
// do something
}
Upvotes: 1