Skip to main content
kineticcreative123
Inspiring
April 8, 2019
Answered

Need popup to close after clicking anchor link.

  • April 8, 2019
  • 1 reply
  • 2558 views

Hello,

I have a popup on a page with a text anchor link that will scroll to a form at the bottom of the page. Is there a way to close it once the anchor link is clicked? It closes when you click outside but it's on top of the form after it scrolls until you do so.

Here is a link to a dummy page I set up for testing.

http://offers.premierinc.com/pop-up-test_pop-up-test.html

Thanks for any help with this.

Update: I just noticed that when closing the popup it takes you to the anchor link regardless where you click. What can I do to stop that?

    This topic has been closed for replies.
    Correct answer osgood_

    Just add a class to the bit of text:

    <p><a href="#form" class="closePopUp"><b>Request a Free Assessment</b></a></p>

    Then add another function to the jquery you already have:

    //close popup

    $('.closePopUp').on('click', function(event){

    $('.bts-popup').removeClass('is-visible')

    });

    1 reply

    osgood_Correct answer
    Legend
    April 8, 2019

    Just add a class to the bit of text:

    <p><a href="#form" class="closePopUp"><b>Request a Free Assessment</b></a></p>

    Then add another function to the jquery you already have:

    //close popup

    $('.closePopUp').on('click', function(event){

    $('.bts-popup').removeClass('is-visible')

    });

    kineticcreative123
    Inspiring
    April 8, 2019

    Nice! As always thank you osgood:)

    Legend
    April 8, 2019

    kineticcreative123  wrote

    How can I get it to stop scrolling to the anchor if you just click off instead of clicking the anchor in the popup?

    Click off what? I don't get any scrolling if you click outside of the popup box, at least not at the example url you provided?