Answers for "js classlist hasclass"

5

js check for class in classList

element.classList.contains(className);
Posted by: Guest on August-27-2020
0

query selector has clas

if (document.body.classList.contains('thatClass')) {
    // do some stuff
}
Posted by: Guest on April-02-2020
2

query selector has clas

document.body.classList.add('thisClass');
// $('body').addClass('thisClass');

document.body.classList.remove('thatClass');
// $('body').removeClass('thatClass');

document.body.classList.toggle('anotherClass');
// $('body').toggleClass('anotherClass');
Posted by: Guest on April-02-2020
1

if classlist contains js

element.classList.contains(class);
Posted by: Guest on December-10-2020
3

classlist

// use the classList API to remove and add classes
div.classList.remove("foo");
div.classList.add("anotherclass");
Posted by: Guest on March-22-2020
0

classlist.contain in javascript

let span = document.querySelector("span");
let classes = span.classList;
let result = classes.contains("d");
if (result) {
  span.textContent = "The classList contains 'c'";
} else {
   span.textContent = "The classList does not contain 'c'";
}
Posted by: Guest on February-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language