Is it possible to display one of the blocks when loading the page, and hide the other, and vice versa when reloading?

  • 0
    The site has two buttons (order a call and sign up).
    It is necessary to display only one randomly when loading.
    For example, on the first visit the user will see "Sign up for a call", and on the third visit "sign up".
    Can this be done in js?
    JavaScript Anonymous, Dec 4, 2019

  • 2 Answers
  • 0
    Write the block state to localstorage and read it on load
    Anonymous

  • 0

    1. By default, both buttons are visible.

    2. The script looks to see if there is information about the previous visit.

    3. If not, hide the random button,

    4. If there is, hide the opposite.

    5. In both cases, save information about the hidden button to the side for future visits.

    Mila Atkinson

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!