与carhartl的jquery插件有一些问题.只是为了让一个粘脚出现..。
这样做的想法是,如果不关闭,页面底部总是会有一个粘贴页脚。很简单。
因此,交叉的onclick触发了两件事情:隐藏粘贴页脚div并追加会话cookie。
现在,它会弹出一秒,然后无限期地隐藏起来。但饼干还没准备好。
<script type="text/javascript">
jQuery(document).ready(function () {
if (jQuery.cookie('stickyNewsClosed') === null) {
jQuery('.stickyFooter').show();
}
if (jQuery.cookie('stickyNewsClosed') !== null) {
jQuery('.stickyFooter').hide();
}
});
</script>
<script type="text/javascript">
function closeSticky(){
jQuery('.stickyFooter').hide();
jQuery.cookie('stickyNewsClosed', 'yup', {
path: '/'
});
}
</script>
也许使用.css() jquery方法而不是.hide() / .show()?
发布于 2014-07-17 21:47:32
嗨,请看这里:http://plnkr.co/edit/yaXgcEsMuNaGu5dQJnL0?p=preview
jQuery(document).ready(function() {
console.log(jQuery.cookie('stickyNewsClosed'));
if (jQuery.cookie('stickyNewsClosed') === undefined) {
jQuery('.stickyFooter').show();
}
else if (jQuery.cookie('stickyNewsClosed') !== null) {
jQuery('.stickyFooter').hide();
}
});
function closeSticky() {
jQuery('.stickyFooter').hide();
jQuery.cookie('stickyNewsClosed', 'yup', {
path: '/'
});
}
https://stackoverflow.com/questions/24813802
复制相似问题