I have a page with many same type of divs as below.
<div class="post_right" data-icon = "arrow-r">
<p>Posted at:</p>
<div class="post_time">
<%= post.created_at.strftime("%I:%M %P") %>
</div>
<div class="post_timer"></div>
</div>
I have a jquery script which will read from “post_time” class and update post_timer class by adding a value to it.
$("document").ready(function() {
$(".post_timer").each(function(){
var post_time = $(".post_time").html()
$(this).html(post_time);
});
});
But all the “post_timer” class value are getting updated by the first post_time value. Any way I can update the post_timer value based on corresponding “post_time” class value all through the page.
1 Answer