English 中文(简体)
• 如何修改既定的《间隔期法》,以在最初的间隔期间采取行动
原标题:How to Modify setInterval Code to Trigger the Interval Action Initially

我不是贾瓦底专家,但我发现一份文字,帮助我完成我需要的东西,但我需要对此作小改动。 这里是《联合材料法典》:

$( html ).addClass( js );

$(function() {

  var timer = setInterval( showDiv, 4000);

  var counter = 0;

  function showDiv() {
    if (counter ==0) { counter++; return; }

    $( #div1, #div2, #div3, #div4 )
      .stop()
      .hide()
      .filter( function() { return this.id.match( div  + counter); })   
      .show( fast );
    counter == 4? counter = 0 : counter++; 

  }

});

and here is an html code:

<div id= container >
<div id= div1  class= display  style="background-color: red;"> 
  div1
</div>

<div id= div2  class= display  style="background-color: green;"> 
  div2
</div>

<div id= div3  class= display  style="background-color: blue;"> 
  div3
</div>
<div id= div4  class= display  style="background-color: yellow;"> 
  div4
</div>
<div>

现在,这本说明是在页数开放后首次展示10秒,然后关闭,然后开放。 我需要改变的是,将这10秒的间隔时间从头四秒中删除,这样它就能够打开一页,并且让其他干.的时间间隔。 我希望你们能理解一下,什么是想实现的。 得到帮助。

最佳回答

简单地称为<代码>showdiv(>) ,是第一次人工操作,高于规定时间,将反初始化推向:

...
var counter = 1;
showDiv();
var timer = setInterval( showDiv, 4000);
...
问题回答

采用以下解决办法:

showDiv();
var timer = setInterval(showDiv, 4000);

var counter = 1;
function showDiv(){
  $( .display ).hide();
  $( #div +counter).show();
  (counter == 4 ? counter = 1 : counter++)
}

www.un.org/Depts/DGACM/index_spanish.htm 工作实例:

You can also utilize the jQuery functions animate() or fadeIn() to apply an effect to the transition.

I would suggest that your first div is visible from the beginning using css. In your javascript do setInterval as you initially programmed. Start your counter as 1. In showDiv raise it. Drop the initial check where you return. For the rest this should work. Get back to me if it doesn t. I ll write the actual code on my pc tomorrow.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签