使用jQuery,可以像这样方便地在元素上添加和删除类:
$('.el').addClass('hey1').removeClass('.hey2')
但是,在Vanilla JS中,我找不到任何方法可以将其添加到一行中,因此添加和删除到两行。
document.querySelector('.el').classList.add('hey1')
document.querySelector('.el').classList.remove('hey2')
是否可以像jQuery一样在1行上都写?