I have two dropdownlist that hold months and years…
$(document).ready(function () {
$('#Months option:eq(' + (new Date).getMonth() + ')').prop('selected', true);
alert((new Date).getMonth());
$('#Years option:eq(' + (new Date).getFullYear() + ')').prop('selected', true);
alert((new Date).getFullYear());
});
I wrote the JQuery script as above so that when my program runs the dropdown selected value must be the current month and year..
but when i execute the program..
the alert gives 7 and 2012.. but in my view the current month is selected but the current year is not why?? and how can I make my dropdown to select current year??
jQuery
HTML
DEMO