Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Created June 12, 2014 15:29
Show Gist options
  • Save adrienjoly/f843b00a01f87e7b420b to your computer and use it in GitHub Desktop.
Save adrienjoly/f843b00a01f87e7b420b to your computer and use it in GitHub Desktop.
hide a div (and keep it hidden forever) when clicking a "close" link
var COOKIE_DEF = "showAd=0", COOKIE_EXP = 365 * 24 * 60 * 60 * 1000; // 1 year
var display = (document.cookie || "").indexOf(COOKIE_DEF) == -1;
var $ad = $("#myAd").toggle(display);
$ad.find(".removeAd").click(function() {
document.cookie = COOKIE_DEF + "; expires=" + new Date(Date.now() + COOKIE_EXP).toGMTString();
$ad.animate({height:0}, function() {
$(this).remove();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment