开发者

Jquery help to loop function call

I have a function timeAgo to which i have to pass timestamp like this... $.timeAgo(timeStamp); it replaces the text with a specific time format.

I have huge ul li structure like this..

<div id="wrapper">
<ul>
<li class="cell">
<div class="timeStamp"></div>
</li>
<li class="cell">
<div class="timeSta开发者_Python百科mp"></div>
</li>
</ul>
</div>

hw do i loop the function call? How do i write it in minified way?


Assuming that the divs with class 'timeStamp' hold the timestamp values, you can loop through them like this:

$( '.timeStamp' ).each( function() {
    $( this ).text( $.timeAgo( $this.text() ) );
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜