2808 explained code solutions for 75 technologies


javascriptCheck if an element has certain class


document.querySelector('#id').classList.contains('check_class');ctrl + c
document.querySelector('#id')

selects certain DOM element with id="id"

classList.contains

will return true if an element has specified class

check_class

name of the class to check