query selector has clas

if (document.body.classList.contains('thatClass')) {
    // do some stuff
}

5
1
Bontae Wood 100 points

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

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

document.body.classList.toggle('anotherClass');
// $('body').toggleClass('anotherClass');

5 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
has class in javascript javascript if window contains class el has class vanilla js check if body has class javascrip has class has class in queryselector has class in query selctor pure javascript has class hasClass typescript definition funcition check form has class js javascript class contain other class pure js if classlist contains es6 if has class how to check condition of query selector queryselectorall in javascript javascript hasClas hashclass javascript hasclass javascript choose between elements in document.queryselector HAS CLASSNAME JAVASCRIPT document.queryselectorall javascript check class contains javascript class has has class in js vanilla js has class javascript dom has class vanilla js elemnt has class plain js has class document has class javascript javascript vanilla class list contains class node.hasClass vanilla js contains class hasclass javascript vanilla js has classname body has class vanilla js pure js has class dosn't hasclass javascript !hasclass javascript hasclass in javascript document.queryselector has class hasclass js vanilla jquery hasclass in javascript javascript classlist has class but not working has class js js .hasclass pure js if has class check class list vanilla js hasclass javascript es6 has class function in javascript hasclass javascript doesnt hasclass vanilla js hasclass vanilla js has class javascript lodash has class hasClass js js classlist hasclass hasclass pure js js has class javascript has class js hasclass vanilla js hasClass has class name in javascript hasclassname javascript is has class javascript has class es6 $(document) has class if hasclass javascript vanilla javascript hasclass select element by attribute javascript javascript hass class js check if an element has a class js check if element has class has class javascript vanillajs has class hasclass in vanilla js vanilla javascript has class querySelector hasclass hasclass pure javascript hasclass contains javascript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source