if text == "JANUARY" var monthSelected = '0';
if text == "FEBRUARY" var monthSelected = 1;
if text == "MARCH" var monthSelected = 2;
if text == "APRIL" var monthSelected = 3;
if text == "MAY" var monthSelected = 4;
if text == "JUNE" var monthSelected = 5;
if text == "JULY" var monthSelected = 6;
if text == "AUGUST" var monthSelected = 7;
if text == "SEPTEMBER" var monthSelected = 8;
if text == "OCTOBER" var monthSelected = 9;
if text == "NOVEMBER" var monthSelected = 10;
if text == "DECEMBER" var monthSelected = 11;
var month = monthSelected;
Итог: Uncaught SyntaxError: Unexpected identifier
Я так понял проблема в синтаксисе.
Полный код скрипта:
<script>
$(function(){
var $li = $('#li_month li'), $sel = $('#selectMonth');
$li.click(function(event) {
event.preventDefault();
var text = $(this).text();
$('#select_month').text(text);
var val = $('[data-html-text="'+text+'"]', $sel).val();
$sel.val(val);
alert(text);
if text == "JANUARY" var monthSelected = '0';
if text == "FEBRUARY" var monthSelected = 1;
if text == "MARCH" var monthSelected = 2;
if text == "APRIL" var monthSelected = 3;
if text == "MAY" var monthSelected = 4;
if text == "JUNE" var monthSelected = 5;
if text == "JULY" var monthSelected = 6;
if text == "AUGUST" var monthSelected = 7;
if text == "SEPTEMBER" var monthSelected = 8;
if text == "OCTOBER" var monthSelected = 9;
if text == "NOVEMBER" var monthSelected = 10;
if text == "DECEMBER" var monthSelected = 11;
var month = monthSelected;
drawCalendar();
});
});
</script>