Archived topic
Close Button on Section
3 replies · Started by Leon on March 13, 2019
Hi Tom,
I've given a section an id of "topBar" and when I click a button, that section will disappear. This is the JS code used:
<script type="text/javascript">
document.getElementById("closeTopBar").onclick = function(){
document.getElementById("topBar").style.display = none;
}
</script>
The code works fine. However, when a user moves to another page, the section will show up again and it's annoying.
Question is: how to make it that when a user clicks the close button on any page, the section will not show up again on any page?
(the section is a global section inserted by hook)
Hi there,
You would need to create a cookie, and then check for the existence of that cookie.
This should help: https://github.com/js-cookie/js-cookie
Thank you Tom. Will see if it works out for me.
No problem :)