I do an animation button with CSS3 that will change the burger to the cross when clicking. How to convert code from pure JS to jQuery?
var toggles = document.querySelectorAll(".cmn-toggle-switch");
for (var i = toggles.length - 1; i >= 0; i--) {
var toggle = toggles[i];
toggleHandler(toggle);
};
function toggleHandler(toggle) {
toggle.addEventListener( "click", function(e) {
e.preventDefault();
(this.classList.contains("active") === true) ? this.classList.remove("active") : this.classList.add("active");
});
}
$(".cmn-toggle-switch").onClick(() => { $(this).toggleClass("active") });this will doonClickin jQuery and nothisin arrow functions$(".cmn-toggle-switch").click(function() { $(this).toggleClass("active"); });right?