$("body"). delegate in Plain javascript

Asked

Viewed 23 times

0

I’m implementing a class calendar events, but when I click the button to go to the next month or earlier, the div events of the selected day of the click event no longer work. If I use the $("body").delegate jQuery’s this would be no problem, but now without jQuery is giving me a certain job.

Note: The calendar is recreated.

var elements = document.querySelectorAll(".in-range");
elements.forEach(element => {
    var classList = element.classList;
    element.addEventListener('click',(e)=>{
        executaData( element.getAttribute('date-value') );
        } else alert('Weekend\'s days not available');
    });
});

1 answer

0

The problem has been solved, the implementation has been thus:

document.addEventListener('click', function (event) {
if (event.target.matches('.in-range'))
    console.log(event.target.getAttribute('date-value'));
}, false);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.