stateful - How to close a div permanently using jQuery -
i have 5 pages , including banner in 1st page, if user closes banner in 1st page banner should not appear in other pages too.
$(document).ready(function(){ $(".alert-banner-hide").on("click", function(){ $("#alert-banner-container").hide(); }); });
could please me on this? in advance.
use sessionstorage
object have stateful :
for on-close banner event :
$(".alert-banner-hide").on("click", function(){ $("#alert-banner-container").hide(); sessionstorage.setitem("banner-closed","yes"); //add instruction });
and
on pages load / document ready :
// copy/paste whole code below & don't worry $(function(){ if (sessionstorage.getitem('banner-closed')==="yes"){ //trigger close banner $("#alert-banner-container").hide(); } })
Comments
Post a Comment