Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* add current progress bar selector to target with CSS */
- $(".progress-bar").has("div.current").addClass("current-pb");
- // mutation observer instance
- var target = $("div.progress-fill");
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (mutation.attributeName === "class") {
- var attributeValue = $(mutation.target).prop(mutation.attributeName);
- if ($(mutation.target).hasClass("current")) {
- $(mutation.target).parent().addClass("current-pb");
- } else {
- $(mutation.target).parent().removeClass("current-pb");
- }
- }
- });
- });
- // observe all progress bars
- var i;
- for (i = 0; i < target.length; i++) {
- observer.observe(target[i], { attributes: true });
- }
Advertisement
Add Comment
Please, Sign In to add comment