Answer the question
In order to leave comments, you need to log in
How to show a message on a jquery cookie for a while?
There is a block with the message class that is shown to new visitors (by cookie, by adding display:block;). If the visitor already has a cookie, then the block is hidden by adding display:none;.
<div class="message">Сообщение</div>
$(function() {
if (!$.cookie('message')) {
$('.message').css({
'display': 'block'
});
}
else {
$('.message').css({
'display': 'none'
});
}
$.cookie('message', true, {
expires: 7,
path: '/'
});
});
setTimeout(function(){$('.message').fadeOut()}, 7200000);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question