I have a problem in converting my websites vanilla js to jQuery
I want to convert
const blue = $('#color-blue'),
red = $('#color-red');
blue.addEventListener('click', () => {
delete chat.dataset.color;
});
red.addEventListener('click', () => {
chat.dataset.color = 'red';
});
to use with jquery
CodePudding user response:
While it is unnecessary to change the event listeners to jQuery, if for some reason you still want this, the below should work for you!
const blue = $('#color-blue'),
red = $('#color-red');
blue.on('click', () => delete chat.dataset.color);
red.on('click', () => chat.dataset.color = 'red');