Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

addclass js vanilla

  element.classList.add('className');
Comment

vanilla javascript add class

document.addEventListener("DOMContentLoaded", function() {
  var faqContainers = document.getElementsByClassName('faq-container')
  var faqToggle = document.getElementsByTagName('body')[0]
  for (var i = 0; i < faqContainers.length; i++) {

    faqContainers[i].addEventListener('click', function() {
      if (faqToggle.classList.contains('faq-display')) {
        faqToggle.classList.remove('faq-display')
      } else {
        faqToggle.classList.add('faq-display')
      }
    })
  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: js fileinput get content 
Javascript :: convert an array of strings to numbers 
Javascript :: javascript leave page warning 
Javascript :: react create app 
Javascript :: create new react project 
Javascript :: jquery when you typing in input 
Javascript :: react-native text overflow ellipsis 
Javascript :: serialize and send form data jquery ajax 
Javascript :: select random element js array 
Javascript :: reset a select option jquery 
Javascript :: skip import angular 6 
Javascript :: javascript scroll to element 
Javascript :: javascript to redirect to another page after 5 seconds 
Javascript :: .gitignore nodejs 
Javascript :: array join javascript new line 
Javascript :: jquery get element by class and data attribute 
Javascript :: change format date javascript 
Javascript :: regular expression for links 
Javascript :: how to pad string js 
Javascript :: hot to make a funtion constantly active JS 
Javascript :: react native flatlist horizontal scroll 
Javascript :: disable input field with jquery 
Javascript :: react bootstrap styles not working 
Javascript :: logout in react js 
Javascript :: eslint console log 
Javascript :: typescript read url parameters 
Javascript :: javascript add event listener to all input 
Javascript :: on window resize react 
Javascript :: Jest encountered an unexpected token 
Javascript :: how to submit using checkbox 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =