Is it possible to display one of the blocks when loading the page, and hide the other, and vice versa when reloading?
-
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 -
Write the block state to localstorage and read it on loadAnonymous
-
- By default, both buttons are visible.
- The script looks to see if there is information about the previous visit.
- If not, hide the random button,
- If there is, hide the opposite.
- In both cases, save information about the hidden button to the side for future visits.
Mila Atkinson - By default, both buttons are visible.
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!