I would like a simple JavaScript code that will allow me to hide a certain div element when clicked for a predefined amount of time. To be a little more informative, I have a suggestions box that appears when the home page is loaded. What I would like is when the div close button is clicked it sets a cookie to keep the box div closed for 24 hours (1day). Simply said, when the div close button is pressed, the box div is hidden for 24 hours. Note: I have a javascript that allows the close button to close the box but it will load every refresh.
Share
Although T.J. Crowder is right in his comment that stackoverflow is not here for writing your code… I wrote some code for you. Here’s a solution using jQuery. In it you’d use a
<div id="popupDiv">...</div>for the message and a link in it with id “close” to close the div.Here’s a js fiddle: http://jsfiddle.net/FcFW2/1/. Run once and then run again. The second time the popup does not show.