检查现有 Cookie 无法正常工作
Checking for the existing cookies doesn't work properly
我想触发点击我的视频以显示页面何时具有特定的cookie。但无论出于何种原因,它对我都不起作用,我是 jQuery 的新手,将感谢您的帮助。
这是我的代码(要查看完整的代码,请在工作 JSFIDDLE 上
jQuery(document).ready(function($) {
jQuery('.video-thumb').click(function() {
var vidId = $(this).attr('id');
var vidBg = $(this).attr('data-bg');
$('#container').html('<iframe data-color="'+vidBg+'" id="player_'+vidId+'" width="420" height="315" src="http://www.youtube.com/embed/' + vidId + '?enablejsapi=1&autoplay=1&autohide=1&showinfo=0" frameborder="0" allowfullscreen></iframe>');
});
});
if (getCookie('username') && getCookie('temp')) {
$( ".initial" ).click();
aler('Cookies are set');
}
我不确定你想做什么,但是在你的小提琴中,你只放置了cookie"用户名",你从未设置cookie"temp",所以这不会执行,因为"临时"cookie不存在:
if (getCookie('username') && getCookie('temp')) {
$( ".initial" ).click();
alert('Cookies are set');
}
如果您只在寻找您应该使用的 cookie 之一
if (getCookie('username') || getCookie('temp')) {
$( ".initial" ).click();
alert('Cookies are set');
}
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JavaScript打印功能使日历停止工作
- Javascript.getHours()工作不正常
- 为什么这在IE中的工作方式与在Firefox中不同
- 视频HTML没有'无法在Internet Explorer 11上工作
- 扩展移相器按钮类不工作
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 正在尝试使用if和else添加类,但无法正常工作
- Jquery FadeIn FadeOut 只工作一次
- Foreach无法在Typescript中工作
- 另一个ajax调用中的Jquery ajax调用在for循环中没有按预期工作
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- JS可以在Chrome中工作,但不能在Firefox中工作
- ajaxToolkit PopupControlExtender不工作.过时的
- HTML标记在脚本标记中工作
- javascript扫雷器floodfill算法不能正常工作