Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

addeventlistener classlist toggle dom

const span = document.querySelector("span");
const classes = span.classList;

span.addEventListener('click', function() {
  const result = classes.toggle("c");

  if (result) {
    span.textContent = `'c' added; classList is now "${classes}".`;
  } else {
    span.textContent = `'c' removed; classList is now "${classes}".`;
  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: axios post method 
Javascript :: split in javascript 
Javascript :: how to convert div to image in jquery 
Javascript :: sequelize contains 
Javascript :: javascript best way to loop through array 
Javascript :: counter in html and js 
Javascript :: js reduce example 
Javascript :: animate change background color angular 
Javascript :: require express server.js 
Javascript :: map javascript 
Javascript :: node.js parameters 
Javascript :: mongoose bulk update 
Javascript :: GET method firebase realtime database react 
Javascript :: Mqtt js react-native 
Javascript :: js check string is date 
Javascript :: javascript the event loop 
Javascript :: how to use nodemailer 
Javascript :: nested include sequelize 
Javascript :: Create An Event With JavaScript 
Javascript :: find object in array 
Javascript :: npm install --save react-draft-wysiwyg draft-js react-draft-wysiwyg-a 
Javascript :: set javascript 
Javascript :: console.log(...) is not a function 
Javascript :: encrypt js 
Javascript :: format iso time in human readable format with moment js 
Javascript :: localstorage api 
Javascript :: discord bot remove message reaction 
Javascript :: js do...while 
Javascript :: clean code javascript 
Javascript :: d3.js 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =