skip to Main Content

Can we make a script that allows to hide certain elements when endpoints are loaded in our website URL???

For example, when someone clicks on a currency option, it creates an endpoint "/?wmc-currency=USD". Or if implemented into the web like this https://www.yoursite.com/product/?wmc-currency=USD.

I want a div or any element to be hidden when "/?wmc-currency=USD" is added to the url.

Any help would be very valuable to me. Thanks very much

2

Answers


  1. Chosen as BEST ANSWER

    This is the code I ended up using, because style.width doesn't hide the text.... So I use display none

      function checkEndpoint() {
      if(window.location.search=="?wmc-currency=USD") {
        document.getElementById('testid')style.display = 'none';
      }
    }
    checkEndpoint();.
    

    But still, I thank you very much


  2. function checkEndpoint() {
      if(window.location.search=="?wmc-currency=USD") {
        document.getElementById('testid').style.width = 0;
      }
    }
    checkEndpoint();
    
    // you can also delete the div if you want but with this, you can always bring 
    // it back without having to remake it

    make sure you change the id for the div you want

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search