showing results for - "jquery observe class change"
Lisa
29 Mar 2017
1var $div = $("#foo");
2var observer = new MutationObserver(function(mutations) {
3  mutations.forEach(function(mutation) {
4    if (mutation.attributeName === "class") {
5      var attributeValue = $(mutation.target).prop(mutation.attributeName);
6      console.log("Class attribute changed to:", attributeValue);
7    }
8  });
9});
10observer.observe($div[0], {
11  attributes: true
12});
13
14$div.addClass('red');