News for hackers. Stuff that matters.
Re:How to manage HTML DOM with vanilla JavaScript only? by jnet on Thursday April 02, 2020 @10:14AM (#22759170)
ele.classList.toggle('class-name');

That seems really useful, and I had no idea it existed.

Re:How to manage HTML DOM with vanilla JavaScript only? by abdusco on Thursday April 02, 2020 @12:46PM (#22760909)
You can also give it a second boolean argument to force add/remove classes.

    let flag = false;
    ele.classList.toggle('has--flag', flag);
will remove the class, for example.

https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenLis...