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() ) );
});
精彩评论