我只想为每个用户或会话显示一次欢迎 div。我知道有 Jquery 选项。由于我是jquery的新手,我自己无法解决这个问题。请帮忙
$(document).ready(function() {
$("#close-welcome").click(function() {
$(".welcome").fadeOut(1000);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="welcome">
<div>
<h1>Hello..!<br> Welcome to ABC
<br>
</h1>
<h2>We wish you a Great Day..!</h2>
<br>
<h2><a id="close-welcome" href="#">Thank you.. and please take me to the website</a> </h2>
</div>
</div>
我只想显示此欢迎页面一次,直到用户关闭浏览器。
等待宝贵的帮助
设置一个cookie。
$(document).ready(function() {
if ($.cookie('noShowWelcome')) $('.welcome').hide();
else {
$("#close-welcome").click(function() {
$(".welcome").fadeOut(1000);
$.cookie('noShowWelcome', true);
});
}
});
您需要包含 jQuery.cookie javascript 文件。
https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)