我已经创建了一个注册表,我希望用户访问该网站时只需注册一次。
我使用的是localstorage,因此当用户单击十字时,它不会显示(因为您只能在选择十字后看到此十字)。
但是,它仍然显示表单。
$(document).ready(function(){
//Get current time
var currentTime = new Date().getTime();
//Add hours function
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}
//Get time after 24 hours
var after24 = new Date().addHours(10).getTime();
//Hide div click
$('.close').click(function(){
//Hide div
$('.popup, .overlay').hide();
//Set desired time till you want to hide that div
localStorage.setItem('desiredTime', after24);
});
//If desired time >= currentTime, based on that HIDE / SHOW
if(localStorage.getItem('desiredTime') >= currentTime)
{
$('.popup, .overlay').show();
}
else
{
$('.popup, .overlay').hide();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="popup">
<div class="cross"></div>
<div class="popup-pad">
<h2>header</h2>
<form id="contact-form" method="post" action="contact.php" role="form">
<div class="messages"></div>
<div class="controls">
<div>
<div class="col-33 fl form-group">
<input id="form_name5" type="text" name="postcode" class="form-control textbox" placeholder="Postcode*" required="required" data-error="Postcode is required.">
<div class="help-block with-errors"></div>
</div>
<div class="clear"></div>
<input type="submit" class="btn btn-success btn-send" value="Enter Prize Draw">
<!--<div class="col-100 form-group">
<input id="form_name7" type="text" name="postcode" class="form-control textbox" placeholder="Postcode*" required="required" data-error="Postcode is required.">
<div class="help-block with-errors"></div>
</div>-->
</div>
</div>
<p id="message"></p>
</form>
</div>
<img src="images/bg.png"/>
</div>
关于如何修改此内容的任何想法。因此,一旦点击了十字架,它将在24小时内不显示?
谢谢