首页 \ 问答 \ jQuery一次淡入/淡出两个div,循环并重复(jQuery fade in/out two divs at a time, looping and repeating)

jQuery一次淡入/淡出两个div,循环并重复(jQuery fade in/out two divs at a time, looping and repeating)

我正在使用Wordpress的高级自定义字段插件,并激活了Repeater字段 ,以便客户端能够添加任意数量的推荐。 推荐书分别显示在前端的.quote div中。 但是,我只希望一次显示两个.quote div(按连续顺序),并且在时间上淡入/淡出两个。

喜欢这个:

页面加载 :显示引号1和2。 7秒过去 :显示报价3和4。 再过7秒 :显示报价5和6。 重复等,不依赖于引用量(可能有.quote等),一旦达到最后两个.quote div,它将.quote重新开始。

我把一些超级简陋的代码拼凑在一起试图说明我的观点: http//jsfiddle.net/9kg6L/

我确信这有一个简单的解决方案,但我仍然是一个写jQuery的新手,所以我希望从这个小经验中学习:)


I'm using the Advanced Custom Fields plugin for Wordpress with the Repeater Field activated to give a client the ability to add as many testimonials as they want. The testimonials are each displayed inside a .quote div on the front-end. However, I only want two .quote divs to be displayed at a time (in consecutive order), and fade in/out two at at time.

Like this:

Page loads: quotes 1 & 2 are shown. 7 seconds go by: quotes 3 & 4 are shown. Another 7 seconds go by: quotes 5 & 6 are shown. Repeat, etc, not dependent on the amount of quotes there are (there could be 20, 5, 18, etc.) and once the last two .quote divs are reached, it will restart from the beginning.

I've thrown together a super rudimentary and terrible bit of code to try and illustrate my point here: http://jsfiddle.net/9kg6L/

I'm sure there's an easy solution for this, but I'm still a newbie writing jQuery, so I hope to learn from this little experience :)


原文:https://stackoverflow.com/questions/15913231
更新时间:2023-01-10 17:01

最满意答案

对于你的第一个问题:对我来说,一个算法可以是一个想法,如“计算你需要的数组的所有元素的总和......”,一个函数(有一个输入和un输出和一些步骤介于两者之间)或一系列数学运算。

因此,算法将是一系列允许从某个地方到其他地方的步骤(使用地铁从家到工作也是一种算法)。

对于你的第二个问题:有两种大的类型(我正在简化)编程语言,“编译”和“interprated”,在后者中你有交互式或脚本语言。 另外,一般来说,脚本语言被认为是高级语言:你可以在几行中组成一个强大的东西,形成一个脚本。

当然一些脚本语言也可以编译....


For your first question : for me an algorithm can be an idea such as "to compute the sum of all the elements of the array you need to.....", a function (there is an input and un output and some steps in between) or a serie of mathematical operation.

So an algorithm would be a serie of steps that allow to go from somewhere to somewhere else (going from your home to your work using the subway is also an algorithm).

For your second question : there are two big types (I'm simplifying) of programming languages, the "compiled" ones and the "interprated" ones and among the latters you have the interactive ones or scripting languages. Also, generally speaking, scripting languages are considered high-levels ones : you can do powerful things in a few lines that together are forming a script.

Of course some scripting language can also be compiled....

相关问答

更多
  • DPLL要求以分离范式表述问题,即作为一组条款,每个条款都必须得到满足。 每个子句都是一组文字{l1, l2, ..., ln} ,表示这些文字的分离(即,至少一个文字必须对于要满足的子句是正确的)。 每个字面l声称某个变量是真( x )或是假( ~x )。 如果在一个条款中任何文字是真的,那么该条款是满意的。 如果一个条款中的所有文字都是错误的,那么该条款是不可满足的,因此这个问题是不可满足的。 解决方案是将真/假值分配给变量,以便满足每个子句。 DPLL算法是针对这种解决方案的优化搜索。 DPLL本质上 ...
  • #是自动加载脚本。 尝试:h autoload获取更多信息。 我不认为允许“显式”函数结束,如vim帮助中所写: :endf[unction] The end of a function definition. Must be on a line by its own, without other commands. 但是看起来当你尝试把东西放在:endf ,即使它不是函数的名字,也不会发生错误。 The # is for autoload scripts. Try ...
  • 在这种情况下,您仍然将其称为jQuery对象上的属性,如下所示: jQuery(document).ready(function() { jQuery('#cancelID').click(function() { jQuery.modal.close(); }); }); 或者在ready函数中使用$ (它作为第一个参数传递),如下所示: jQuery(function($) { $('#cancelID').click(function() { ...
  • 您可以使用eval运行字符串中定义的代码。 像这样: import sys x = load_some_data() function = eval("".join(sys.argv[1:])) print(function(x)) 使用您的具体示例,您可能必须使用lambda x: len(x) 正如@ Jan-Spurny正确地指出的那样:“永远,永远,永远不要使用eval,除非你绝对确定没有别的办法。即便如此,你应该停下来思考一下。” 在我看来,更好的策略是将数据加载器和执行器转换为一个模块,该模 ...
  • 对你的问题的简短回答是,是的,这是可能的。 更长一点的答案是谷歌积极尝试用Captchas和其他反刮策略来阻止这种刮擦,因此像对谷歌进行15,000次调用这样简单的解决方案不可能比手动操作快得多。 幸运的是,有一个免费的库,旨在解决这个问题。 您可以在http://scraping.compunect.com/找到它。 (为了记录,我与图书馆的作者没有任何关系。) The short answer to your question is, yes, this is possible. The somewha ...
  • 如上所述,正确的答案是: a)将SQL脚本保存在单独的文件中 b)有一个合适的版本控制系统(Git等) c)从版本控制系统部署 木已成舟。 As found, the correct answer is to: a) Maintain your SQL Scripts in separate files b) Have a proper versioning system (Git, etc.) c) Deploy from the versioning system Done Deal.
  • 尝试制作它...... #!/bin/bash TIME_CMD='/usr/bin/time -f "%E execution time"' eval "$TIME_CMD ls" 这将利用bash在构造命令字符串后重新解析它,以便正确识别引用的参数。 Try making it... #!/bin/bash TIME_CMD='/usr/bin/time -f "%E execution time"' eval "$TIME_CMD ls" This will utilize bash to r ...
  • 对于你的第一个问题:对我来说,一个算法可以是一个想法,如“计算你需要的数组的所有元素的总和......”,一个函数(有一个输入和un输出和一些步骤介于两者之间)或一系列数学运算。 因此,算法将是一系列允许从某个地方到其他地方的步骤(使用地铁从家到工作也是一种算法)。 对于你的第二个问题:有两种大的类型(我正在简化)编程语言,“编译”和“interprated”,在后者中你有交互式或脚本语言。 另外,一般来说,脚本语言被认为是高级语言:你可以在几行中组成一个强大的东西,形成一个脚本。 当然一些脚本语言也可以编 ...
  • 调用dbms_metadata.get_ddl是一种选择。 例如 SET LONG 10000 SELECT dbms_metadata.get_ddl('TABLE', 'MY-TABLE-NAME') FROM dual; 或者,许多GUI工具(包括TOAD和企业管理器)都有DDL生成器。 Calling dbms_metadata.get_ddl is one option. e.g. SET LONG 10000 SELECT dbms_metadata.get_ddl('TABLE', ...
  • 我个人更喜欢使用哈希映射/字典来处理这些名称/值对。 所以你的代码可以写成: var buttonMap:Dictionary = new Dictionary(); buttonMap["TD_g"] = "Tweedlee_Dee"; buttonMap["s_g"] = "Sincerely"; buttonMap["ats_g"] = "Ain’_that_a_shame"; buttonMap["iyk_g"] = "I_hear_you_knocking"; buttonMap["hms_g"] ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)