[英]How do I allow users to close a slide using this JQuery example?
I would like to get users to sign up to my email newsletter without using annoying popups. 我想让用户注册我的电子邮件时事通讯,而不必使用烦人的弹出窗口。
I discovered a scroll-activated JQuery slide that I think will work well. 我发现了一个滚动激活的JQuery幻灯片,我认为它将很好地工作。
Here is the test example I created: (scroll down to activate it) 这是我创建的测试示例:(向下滚动以激活它)
http://buckinvestor.com/test/jquerytest.html http://buckinvestor.com/test/jquerytest.html
Now here is the problem: I don't want to annoy users by constantly having this slide down on each page. 现在是问题所在:我不想不断在每个页面上放下这张幻灯片来惹恼用户。
How do I add a "Close" button to the slide? 如何在幻灯片上添加“关闭”按钮?
How do I ensure that the user doesn't see the slide again after they click close? 如何确保用户单击关闭后不会再次看到幻灯片? (perhaps a cookie that stays active for 7 days or something?, not sure how that works, but if you provide me some guidance, I'll figure it out).
(也许一个cookie可以保持活动7天之久??不确定其工作原理,但是如果您提供一些指导,我会解决的)。
Thank you everyone - StackOverflow has been such a lifesaver! 谢谢大家-StackOverflow真是救命稻草!
Easy 简单
you just need to hide the DIV in this example add a button or image and use the live('click',function(){}) 您只需要在此示例中隐藏DIV,即可添加按钮或图像并使用live('click',function(){})
$('#closediv').live('click',function(){
$('#headerSlideContainer').hide();})
as for the second part of the question yes cookie 至于问题的第二部分,是cookie
For #1, just add a button and 对于#1,只需添加一个按钮,然后
$("button.hide").click(function(event){ $("div.hidethis").hide() });
onclick to hide the div that is the slide thing. onclick隐藏作为幻灯片对象的div。
Add a <a>
or <button>
or something for the close button inside of the #headerSlideContent <div>
为#headerSlideContent
<div>
内的关闭按钮添加<a>
或<button>
或其他内容。
Add a on click or similar to the button inside your load function: 在加载功能内添加一个单击或类似按钮:
$('#closeButton').click(function(){
$('#headerSlideContainer').hide();
});
http://api.jquery.com/hide/ http://api.jquery.com/hide/
For part 2, yes a cookie is good, I found the jQuery cookie plugin to be helpful: http://plugins.jquery.com/project/Cookie 对于第2部分,是一个cookie很好,我发现jQuery cookie插件很有帮助: http : //plugins.jquery.com/project/Cookie
Set the cookie: $.cookie("name", "value");
设置cookie:
$.cookie("name", "value");
Read the cookie: var value = $.cookie("name");
读取cookie:
var value = $.cookie("name");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.