Answer the question
In order to leave comments, you need to log in
How to show element temporarily on Jquery Cookie?
Tell me how to show an element to a new person using the Jquery Cookie plugin, but not to the old one. But there is a condition - that the old user needs to show the element only for a while. That is, after 24 hours, the old user should not see this element.
Answer the question
In order to leave comments, you need to log in
var cookieVal = $.cookie('newUser'});
if(!cookieVal) {
$.cookie('newUser', Date.now());
}
else {
var dayInSeconds = 86400
var currentDate = Date.now()
var dateDiff = currentDate - parseInt(cookieDate)
if( dateDiff < dayInSeconds ) {
showElement()
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question