Created
May 23, 2018 09:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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