【发布时间】:2016-03-03 16:56:18
【问题描述】:
我正在尝试创建一个模式显示,该显示在使用 zurb Foundation 6 的页面加载时打开。我还希望浏览器存储一个 cookie,以便如果用户关闭显示,它不会再打扰他们 7 天。
我正在使用一个 jquery 插件来找到 here 的 cookie
这是我的html:
<div class="reveal" id="exampleModal1" data-reveal>
<h1>Awesome. I Have It.</h1>
<p class="lead">Your couch. It is mine.</p>
<p>I'm a cool paragraph that lives inside of an even cooler modal. Wins!</p>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
如您所见,我没有数据打开元素,因为我希望在页面加载后打开模式。
这是我的 jquery:
jQuery(document).ready(function($) {
if ($.cookie('modal_shown') === null) {
$.cookie('modal_shown', 'yes', { expires: 7, path: '/' });
$("#exampleModal1").foundation('reveal', 'open');
}
});
jquery 处于无冲突模式。
但这似乎不起作用。我在 chrome 中通过我的开发者控制台没有收到任何错误。我非常感谢您的帮助。
【问题讨论】:
标签: javascript jquery cookies zurb-foundation