Reputation: 1246
How can i get all option values of dropdown? And can i hide them, by they value? For example i have dropdown list with 12 monthes, now is 11 october 2012, and i'd like to hide all monthes from past, and show only 3 - October, November, December.
Here is how i try to da that, can u tell me, how can i get the option value in that loop, because this.val()
do not return it?
var currentTime = new Date();
var month = currentTime.getMonth();
var year = currentTime.getFullYear();
if (year == $('#yearSelected', '#BookingCalendar').val()){
$('#monthSelected option', '#BookingCalendar').each(
function (){
if(this.val() < month) this.hide();
}
);
}
Upvotes: 0
Views: 110
Reputation: 145368
Check the following line:
if (this.value < month) // 'this' is DOM object
$(this).hide(); // '$(this)' is jQuery object
Upvotes: 1