English 中文(简体)
j 优质或 Java字连续反射(计数)
原标题:jQuery or Javascript continuous counter (countup)

看一看我最好能读到的文字,从一开始,一开始,一开始,一开始,就继续根据我确定的标准,例如每秒钟1。 文字最好根据目前时间与起算时间之间的差别计算其数目。

它意在像它那样看一生。

Ideally, some such as the Counter on http://sendgrid.com/

是否有任何人能够分享联系或原始或解决办法?

如果能够用数字图像来取代数字,那么起点将受到高度赞赏。

增 编

最佳回答

如果你只想用 j子解决问题,那么你就能够这样做:

<div id="counter"></div>

然后在网页上使用以下文字:

var START_DATE = new Date("July 27, 2010 13:30:00"); // put in the starting date here
var INTERVAL = 1; // in seconds
var INCREMENT = 2; // increase per tick
var START_VALUE = 9001; // initial value when it s the start date
var count = 0;

window.onload = function()
{
 var msInterval = INTERVAL * 1000;
 var now = new Date();
 count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE;
 document.getElementById( counter ).innerHTML = count;
 setInterval("count += INCREMENT; document.getElementById( counter ).innerHTML = count;", msInterval);
}

你们可以采用类似于化武库的技术来获取图像,或者说,你可以把反照带给安全局。

问题回答

也许有一页,有这个标记:

<div id= counter ><%= some_number_from_database_or_similar() %></div>

因此,你可以撰写这样的文字:

var INTERVAL = 1;

$(document).ready( function() {
  var delay = INTERVAL * 1000;
  var target = $( #counter );
  var counter = parseInt( target.text(), 10 );
  setInterval( function() {
    target.text( counter++ );
  }, delay );
} );

这是完全准确的,因为你可以肯定,这项职能将每秒一次被称作exactly,但代价是相当接近的(以及你真的需要是怎样准确的? 或者,你可以建立一个<代码>新日期()并把它放在时间序列上,然后每间隔再造一个字,然后计算实际数字。 种子价格太高,价值太高。

在将图像用于数字方面,你只能改变间隔功能,如:

function() {
  var counterString = (counter++).toString();
  var chunks = [];
  for( var i = 0; i < counterString.length; i++ ) {
    chunks.push( "<img src= /images/numbers/" + counterString[i] + ".png  />" );
  }
  target.html( chunks.join(  ) );
}

您可在自己的<>或的基础上再接再厉。 仅使用plugin。 a countup 在那里。





相关问题
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.

热门标签