简体   繁体   English

如何允许用户使用此JQuery示例关闭幻灯片?

[英]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. 现在是问题所在:我不想不断在每个页面上放下这张幻灯片来惹恼用户。

  1. How do I add a "Close" button to the slide? 如何在幻灯片上添加“关闭”按钮?

  2. 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.

相关问题 如何向下滑动一个标签并关闭其他所有打开的标签(JQuery / JavaScript) - How do I slide down one tab and close any others that are open (JQuery/JavaScript) 如何将此滑动面板 jQuery 插件设置为默认关闭? - How can I set this slide panel jQuery plugin to default close? 如何在调整大小时关闭滑入式导航栏? - How do I close a slide-in nav bar on resize? 如何使用JQuery关闭此对话框? 使用Coffeescript? - How do I close this dialog using JQuery? Using Coffeescript? 如何允许用户使用 php html css js 在 wyswg 中自定义电子商务商店主题 - How do I allow users to customize e commerce store themes in wyswg using php html css js jQuery-幻灯片示例 - JQuery - Slide Example 使用jQuery单击按钮后,如何跳到特定幻灯片? - How do I jump to a specific slide upon clicking a button using jQuery? 当有人使用jQuery单击子导航项时,如何在Flexslider中显示特定幻灯片? - How do i show a specific slide in Flexslider when someone clicked on sub nav item using jQuery? 如何使用jquery从左到右或从右到左滑动图像? - how do i slide images left to right or right to left using jquery? 如何在页面加载时使用javascript / jquery滑动/打开特定菜单项? - How do I slide/open specific menu item using javascript / jquery on page load?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM