Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change elements class javascript

document.getElementById("MyElement").classList.add('MyClass');

document.getElementById("MyElement").classList.remove('MyClass');

if ( document.getElementById("MyElement").classList.contains('MyClass') )
{
document.getElementById("MyElement").classList.toggle('MyClass');
}
Comment

javascript change element class

//Overwrite all classes
element.className = "class";

//Add class
element.classList.add("class");
Comment

change class js

let containsClass = element.classList.contains('my-class');
element.classList.toggle('my-class', !containsClass);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery uncheck checkbox 
Javascript :: Unhandled rejection TypeError: Article.findById is not a function sequelize 
Javascript :: javascript search in array of strings 
Javascript :: countTo add commas to number jquery 
Javascript :: jquery in checkbox checked 
Javascript :: javascript string get last two character 
Javascript :: if window undefined 
Javascript :: remove unused dependencies in React Ask Question 
Javascript :: tailwind css calc 
Javascript :: how to fix cors in angular 
Javascript :: delete empty values from object js 
Javascript :: vue js footer copyright date automatically 
Javascript :: javascript change long digit ot k,m 
Javascript :: detect keypress javascript 
Javascript :: node pre gyp error 
Javascript :: jquery insert text into input 
Javascript :: import fa icons react 
Javascript :: lodash combine permissions 
Javascript :: js add string to beginning of string 
Javascript :: open submenu jquery 
Javascript :: Delete object in array with filter 
Javascript :: javascript sort array with objects 
Javascript :: put two buttons in a row in react native 
Javascript :: input type number react native 
Javascript :: javascript custom events with data 
Javascript :: Playing sound in Vue.js 
Javascript :: how to check if 2 images are touching js 
Javascript :: get ng content element angular 2 
Javascript :: javascript foreach object key 
Javascript :: fetch request to GraphQL 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =