[Resolved] Top Bar and Close button Vanilla JS

Home Forums Support [Resolved] Top Bar and Close button Vanilla JS

Home Forums Support Top Bar and Close button Vanilla JS

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1347757
    Suraj Katwal

    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.

    View post on imgur.com

    #1347966
    David
    Staff
    Customer Support

    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.

    #1348446
    Suraj Katwal

    Thank You

    #1348525
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.