开发者

Jquery help to loop function call

开发者 https://www.devze.com 2023-03-24 11:57 出处:网络
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 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

精彩评论

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

关注公众号