[英]Convert vanilla js to jquery
我在将我的网站 vanilla js 转换为 jQuery 时遇到问题
我想转换
const blue = $('#color-blue'),
red = $('#color-red');
blue.addEventListener('click', () => {
delete chat.dataset.color;
});
red.addEventListener('click', () => {
chat.dataset.color = 'red';
});
与 jquery 一起使用
虽然没有必要将事件侦听器更改为 jQuery,但如果由于某种原因您仍然想要这个,下面的内容应该适合您!
const blue = $('#color-blue'),
red = $('#color-red');
blue.on('click', () => delete chat.dataset.color);
red.on('click', () => chat.dataset.color = 'red');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.