Skip to content

Instantly share code, notes, and snippets.

@suryadana
Created May 23, 2018 09:47
Show Gist options
  • Save suryadana/253bfef6f44b7eb97dcfcf525b76bf86 to your computer and use it in GitHub Desktop.
Save suryadana/253bfef6f44b7eb97dcfcf525b76bf86 to your computer and use it in GitHub Desktop.
Script for detect attribute value you can custome with callback function inside on mutation observer
$(document).ready(function(){
let list = document.querySelectorAll('.card-header');
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
let observer = new MutationObserver(function(mutations) {
let mutation = mutations[0]
let element = $(mutation.target)
if (element.attr('aria-expanded') === 'true'){
element.removeClass('bg-white').css('background-color', '#f58508')
}else{
element.addClass('bg-white')
}
})
list.forEach(function(node){
observer.observe(node, {
attributes: true,
childList: true,
characterData: true
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment