Convert vanilla js to jquery

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

>Solution :

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');

Leave a Reply