Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading