V
V
Vadim Efremov2017-05-13 09:54:26
JavaScript
Vadim Efremov, 2017-05-13 09:54:26

How to show div on click and remember in cookies?

Hello
There is a script that, when you click on a link, hides a div and writes it to cookies
. Everything works.

<div class="col" id="box1">
<a id="url1" href="#" target="_blank">ССЫЛКА1</a>
</div>

<script type="text/JavaScript"> 
  $(document).ready(function (){ 
  var box1 = $.cookie('box1')//Получаем значение куки 
  if(box1 =='none'){//Делаем проверку 
  $('#box1').remove();//И закрываем блок если куки есть 
  } 
  $('#url1').click(function() {//При клике на id кнопки закрытия 
  $('#box1').slideUp(1000);//Закрываем сам id блока 
  $.cookie('box1', 'none', { expires: 7});//И создаём куку 
  }); 
  }); 
  </script>


PLEASE TELL How to do the opposite - It is necessary that when you click on the link the other way around - DO NOT HIDE the div for 7 days, but show it for 7 days

<div class="col" id="box1" style="display: none">
<a id="url1" href="#" target="_blank">ССЫЛКА1</a>
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question