Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: