J
J
jelezo2015-09-21 02:14:18
JavaScript
jelezo, 2015-09-21 02:14:18

How to hide div for non first visit of user?

There are two content divs:

<div id="first">Первый</div>
<div id="first">Второй</div>

How can I make sure that the first div is not shown for those who have not visited the site for the first time through javascript, using cookies?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-09-21
@jelezo

We take the functions of getting and setting cookies from here .

window.onload = function(){
  if(getCookie("block_visible")||setCookie("block_visible", 1, {expires:1e9})&&false){ 
    document.querySelector(".block").style.display = "none";
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question