Skip to content

JavaScript에서 Onclick오류 (Onclick Error in JavaScript) #21477

Discussion options

You must be logged in to vote

Hello @alsgpwns, welcome to the GitHub Support Community!

Since you’re incrementing and decrementing numbers, I would recommend using the -- and ++ operators. This way the changes made to mm will be stored temporarily in memory and allow you to move forward or backward.

Here is the updated code (see the IF statements at the top of each function):

function onLeftClickTest() {
    if (mm != 0) mm--; // decrement mm if NOT 0 (January)
    firstdayInst = new Date(yyyy, mm, 1); 
    getfirstday = firstdayInst.getDay(); 
    lastdayInst = new Date(yyyy,mm,0);
    lastday = lastdayInst.getDate();
    showMonth(mm);
    showDay();
    showDate();
document.getElementById('CalendarBody').innerHTML=…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants