1

Как мне возвращать переменную mouth?

createCalendar(calendar, 2021, mouth + 1);

function ListenDate() {
    let left_arrow = document.getElementById('left-arrow');
    let right_arrow = document.getElementById('right-arrow');

    left_arrow.onclick = function() {
        mouth -= 1;
        console.log(mouth);
       return mouth;
    };

    right_arrow.onclick = function() {
        mouth += 1;
        console.log(mouth);
        return mouth;
    };
 }
0

1 ответ 1

2

Возвращать никак, только как-то так - функцию calendarUpdate создать, и из кликов отправлять значение туда - для изменения 🙃

const calendar = document.getElementById('calendar_Probably?');
let mouth = 0;

createCalendar(calendar, 2021, mouth + 1);

const calendarUpdate = (newMounth)=>{
    calendar.value = newMounth;
};

const listenDate = ()=>{
    const left_arrow = document.getElementById('left-arrow');
    const right_arrow = document.getElementById('right-arrow');

    left_arrow.onclick = ()=>{
        mouth -= 1;
        console.log('L', mouth);
        calendarUpdate(mouth);
    };

    right_arrow.onclick = ()=>{
        mouth += 1;
        console.log('R', mouth);
        calendarUpdate(mouth);
    };
};

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.