Archived topic
Top Bar and Close button Vanilla JS
3 replies · Started by Suraj Katwal on June 30, 2020
Hi, I am using Top Bar widget and I make it sticky too with a close button.
Can you please assist me with Vanilla JS to hide the top bar when I click the Close button.
https://i.imgur.com/sK6IWVy.png
Hi there,
the JS for it is quite simple as you're running jQuery you could do this for example:
jQuery(document).ready(function($){
$(".wplogout-close-btn").click(function(){
$(".top-bar").hide();
});
});
or instead of hide() you could use another function such as addClass()
https://www.w3schools.com/jquery/html_addclass.asp
But... thats the simple part, the difficult part is 'remembering' the user has clicked the button so it doesn't re-appear on every page and every new visit. That unfortunately requires custom development and is way out of our scope.
Thank You
You're welcome