I would like to know how to select all elements with class names \"widget\" and \"hover\" and then remove class \"hover\" from these elements.
I have the following J
var elems = document.querySelectorAll(".widget.hover");
[].forEach.call(elems, function(el) {
el.classList.remove("hover");
});
You can patch .classList into IE9. Otherwise, you'll need to modify the .className.
var elems = document.querySelectorAll(".widget.hover");
[].forEach.call(elems, function(el) {
el.className = el.className.replace(/\bhover\b/, "");
});
The .forEach() also needs a patch for IE8, but that's pretty common anyway.