Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

GET and CHANGE the class of an element

const mssg = document.querySelector('p');//get the class of the p tag
console.log(mssg.getAttribute('class'));//the class is currently 'error'
mssg.setAttribute('class', 'success');//now the p tag's class is changed to 'success'
console.log(mssg.getAttribute('class'));//the new class of the p tag is 'success'
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop over documents in mongoose 
Javascript :: jest Cross origin http://localhost forbidden 
Javascript :: js event handlers 
Javascript :: react this.state 
Javascript :: get element by id two ids 
Javascript :: content uri react native fs 
Javascript :: simple nodejs server 
Javascript :: alpine js x-on click not working 
Javascript :: Destructuring array and object from a nested object 
Javascript :: javascript date from string dd/mm/yyyy HH mm ss 
Javascript :: insert a string in another js 
Javascript :: send sms with twilio 
Javascript :: global catch in javascript 
Javascript :: regex exact match 
Javascript :: react new project 
Javascript :: react-beforeunload react navive 
Javascript :: .keys() array 
Javascript :: javascript problem solving interview questions 
Javascript :: ng-true-value 
Javascript :: js ?. 
Javascript :: find array in js 
Javascript :: what hostings can run react js 
Javascript :: jquery in javascript 
Javascript :: create window electron 
Javascript :: js array map skip element 
Javascript :: how to decode jwt token at frontend 
Javascript :: get array by array of indices js 
Javascript :: axios get request 
Javascript :: how can I send form data with image in angular 
Javascript :: inline styling javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =