How to toggle class of element in JavaScript

DOM
By Jad Joubran · 
Last updated Sep 22, 2018
<div id="box" class="highlighted"></div>
const element = document.querySelector("#box");

element.classList.toggle("highlighted");