Reputation: 191
I have a page with an unordered list built like this:
<ul id='shows'>
<div id='playlist_sections'>
<li class='sect'><span class='duration'>155</span>Section 1</li>
<li class='sect'><span class='duration'>248</span>Section 2</li>
<li class='sect'><span class='duration'>856</span>Section 3</li>
</div>
</ul>
What I would like to do is after the page loads have some jQuery code loop through all the
<span class='duration'>248</span>
numbers and convert the numbers into hh:mm:ss. So that 248 becomes 2:08. I think I can probably find somewhere else how to convert the seconds into hh:mm:ss, but what I don't know how to do is loop through each span element and replace it with the result of the conversion.
Thanks
Upvotes: 0
Views: 280
Reputation: 31033
you can try
$("span").each(function(){
var text = $(this).text();//get the currently looped span's text
//your conversion code here
$(this).text(/*calculated hh:mm:ss here*/);
});
Upvotes: 1