Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js listen for class change event

const btn = document.querySelector('.btn')
const options = {
  attributes: true
}

function callback(mutationList, observer) {
  mutationList.forEach(function(mutation) {
    if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
      // handle class change
    }
  })
}

const observer = new MutationObserver(callback)
observer.observe(btn, options)
Comment

PREVIOUS NEXT
Code Example
Javascript :: replace data in files in node.js 
Javascript :: react native create shadows 
Javascript :: how to get the max value of two variables in math 
Javascript :: statusbar reactnati 
Javascript :: addclass jquery 
Javascript :: Vue use props in style 
Javascript :: jsconfig.json 
Javascript :: axios get status code 
Javascript :: To append dropdown option using jquery 
Javascript :: get month in two digit in javascript date 
Javascript :: write own nodemon in package.json 
Javascript :: window scroll down javascript 
Javascript :: json javascript 
Javascript :: confetti for javascript 
Javascript :: match password and confirm password in javascript if true then submit form 
Javascript :: giving an html element own attribute using js 
Javascript :: jquery select attribute 
Javascript :: data table 
Javascript :: multiline comment in react 
Javascript :: set value array input jquery 
Javascript :: epoch time js 
Javascript :: how to reset settimeout in javascript 
Javascript :: mongoose delete property 
Javascript :: js get certain number of elements from array 
Javascript :: scrollbar automatically scroll down as new divs are added reactjs 
Javascript :: search substring in string javascript 
Javascript :: js addeventlistener hover 
Javascript :: javascript function argument type 
Javascript :: current date minus days javascript 
Javascript :: react native dimensions window vs screen 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =