Tiggles ツ of Speak Creative
11/28/2018 - 5:41 PM

add body class when alert is active

This snippet will add a class to the body when the page alert is active. Useful for styling page based on presence of alert.

$(document).ready(function() {

if ($(".page-alert-message").size() > 0) {
  var inlineStyle = $('.page-alert-message').attr('style');
  if (inlineStyle == "display:none") {
    $("body").removeClass("message-bar-active");
  } else {
    $("body").addClass("message-bar-active");
  }
}


$('#page-alert-dismiss').click(function() {
  $("body").removeClass("message-bar-active");
});

}); //end doc ready