带有 jQuery cookies 的多样式表(弹出框问题)
$(function() {
$('#yes a').click(function() {
$.cookie('AutoPlayTrue', '1', {
expires: 999
});
$('.disableAutoPlay').hide('slow');
$.cookie('ccss_remembered_style', null);
$.cookie('AutoPlayFalse', null);
});
$('#ccss-no a').click(function() {
$.cookie('AutoPlayFalse', '1', {
expires: 999
});
$('.disableAutoPlay').hide('slow');
$.cookie('AutoPlayTrue', null);
});
if ($.cookie('AutoPlayFalse') === null) {
$('.disableAutoPlay').show();
}
else {
$('.disableAutoPlay').hide();
}
if ($.cookie('AutoPlayTrue') === null) {
$('.disableAutoPlay').show();
}
else {
$('.disableAutoPlay').hide();
}
});
我有一个带有 HTML 的弹出框:
<li class="widget ccss" id="ccss-widget-3"><h2 class="widgettitle">Should HipHop97.com Automatically Start Playing Music?</h2>
<ul id="ccss-list">
<li id="ccss-no"><a href="http://hiphop97.com/wp-content/themes/hiphop/noAutoPlayCSS.css">No</a></li><li id="yes"><a href="#">Yes</a></li>
</ul>
</li>
当选择“是”按钮时,我需要充当“关闭”,并且使用 cookie“不再显示”和“否”按钮,我已经得到了样式表和内容代码已解决,我只需要它不要再次显示带有 cookie 的框。 (该元素位于主题中,只是标记为 display:none;
它位于主容器的顶部。)
我尝试了这个,我认为这是一个很好的概念,但它不起作用:
<script type="text/javascript">
jQuery(document).ready(function($) {
if ($.cookie('AutoPlayFalse')) {
$('.displayAutoPlay').css('display','none !important');
}
if ($.cookie('AutoPlayTrue')) {
$('.displayAutoPlay').css('display','none !important');
}
});
</script>
$(function() {
$('#yes a').click(function() {
$.cookie('AutoPlayTrue', '1', {
expires: 999
});
$('.disableAutoPlay').hide('slow');
$.cookie('ccss_remembered_style', null);
$.cookie('AutoPlayFalse', null);
});
$('#ccss-no a').click(function() {
$.cookie('AutoPlayFalse', '1', {
expires: 999
});
$('.disableAutoPlay').hide('slow');
$.cookie('AutoPlayTrue', null);
});
if ($.cookie('AutoPlayFalse') === null) {
$('.disableAutoPlay').show();
}
else {
$('.disableAutoPlay').hide();
}
if ($.cookie('AutoPlayTrue') === null) {
$('.disableAutoPlay').show();
}
else {
$('.disableAutoPlay').hide();
}
});
I have a pop up box with the HTML:
<li class="widget ccss" id="ccss-widget-3"><h2 class="widgettitle">Should HipHop97.com Automatically Start Playing Music?</h2>
<ul id="ccss-list">
<li id="ccss-no"><a href="http://hiphop97.com/wp-content/themes/hiphop/noAutoPlayCSS.css">No</a></li><li id="yes"><a href="#">Yes</a></li>
</ul>
</li>
I need when the 'yes' button is selected just act as a 'close' and with cookies 'don't show me again' and the 'no' button I've already got the style sheet and stuff code worked out I just need it to not display the box again with cookies. (The element is in the theme, just marked as display:none;
it's at the top of the main container.)
I tried this, it's a good concept I suppose, it just doesn't work:
<script type="text/javascript">
jQuery(document).ready(function($) {
if ($.cookie('AutoPlayFalse')) {
$('.displayAutoPlay').css('display','none !important');
}
if ($.cookie('AutoPlayTrue')) {
$('.displayAutoPlay').css('display','none !important');
}
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白为什么你要把它复杂化:)
I dont understand why do you over complicate it as much :)