【发布时间】:2013-05-02 11:49:34
【问题描述】:
<!-- Modal -->
<div id="appsmodal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') == 0)
{
$('#appsmodal').modal('show');
$.cookie('msg', 1);
}
});
</script>
我已经困惑了大约一个小时,但无济于事。在我用尽所有资源之前,我宁愿不提问。
【问题讨论】:
-
这是一个 .length 的东西吗? if (!$.cookie('msg').length) 或类似的?如果未设置 Cooke 'msg',则它不会等于 0。它就不会存在。
-
.length?嗯? jquery cookie.js 和引导模式
-
我想知道你的 if "if($.cookie('msg') == 0) 是否永远不会返回 true,因为如果你没有设置 $.cookie('msg'),它不会 == 0。它只是不存在。但是,询问 $.cookie('msg').length == 0 是否可能会返回您要查找的内容。
-
也不起作用
-
好的,但是首先,如果您删除 if 语句,cookie 是否设置?比如说,如果你将它设置为“foo”,而不是 1,你可以在 chrome 检查器、firefox firebug 或你有什么中查看它吗?另外,您的浏览器控制台是否显示任何错误或消息?
标签: jquery twitter-bootstrap jquery-cookie