Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:37:36+00:00 2026-05-30T17:37:36+00:00

I have a trouble with jquery each. this each block; $(document).ready( function(){ $(‘td.trh’).each(function(index) {

  • 0

I have a trouble with jquery each. this each block;

$(document).ready( function(){  
    $('td.trh').each(function(index) {
        frk=fark($(this).text()); // frk useless variable
        $('td.sure').eq(index).text(frk); // can be $('td.sure').eq(index).text(fark($(this).text()));
    });
});

td.trh have date like “2012-03-02 11:25:30” and i have try to calculate the time passing over.. thats perfectly worked for first item but after that every loop stop working.

if i call a function like simdi(); without parameter,each perfectly worked..

fark function like;

function saat(trh){ //trh=2012-03-02 11:25:30
    kes=trh.indexOf(' ');
    kes++;
    saat = trh.substring(kes); //saat=11:25:30
    sparca = saat.split(":");
    sTOsn=sparca[0] * 60 * 60; //sparca[0]=11 and 60*60 for hour to sec conversion
    dkTOsn=sparca[1] * 60; //sparca[1]=25 and 60*60 for minute to sec conversion
    sn=sparca[2] * 1;
    sn=sTOsn+dkTOsn+sn; // all of this saat function  for calculate time in sec
    return sn;
}
function simdi() {
    var now = new Date();
    var s = now.getHours();
    var dk = now.getMinutes();
    var nsn = now.getSeconds();
    sTOsn=s * 60 * 60;
    dkTOsn=dk *60;
    rsn = nsn + dkTOsn + sTOsn; // all of this simdi function  for calculate current time in sec
    return rsn;
}
function fark(trh) {
    ssaat=saat(trh); // parameter date calculating in sec
    suan=simdi(); // current date calculating in sec
    snc=suan-ssaat; // calculating beetween parameter date and current date time difference
    hh= snc / 3600 | 0;
    mm= (snc - (hh*3600)) / 60 | 0;
    ss= snc % 60;
    return (hh < 10 ? "0" : "") + hh + (mm < 10 ? ":0" : ":")+ mm + (ss < 10 ? ":0" : ":")+ ss; // and formating time differenc like hour:minute:second
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:37:37+00:00Added an answer on May 30, 2026 at 5:37 pm

    Statement

    saat = trh.substring(kes);
    

    overrides your function saat. Change it to

    var localSaat = trh.substring(kes);
    

    and the next statement to

    var sparca = localSaat.split(":");
    

    You should always use var in front of local variables in the function so that they don’t become global and polute the global namespace (and cause problems like this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some trouble with jquery ui-events: In my application, there are some sliders.
I'm a jQuery newbie, and I have trouble with a little script I created.
I have trouble when designing classes like this class C1 { public: void foo();
I have a jQuery issue I can't get past: (function ($) { var links
I'm a jquery/rails newbie and I'm having trouble using .sortable(). I have expandable rows
I have some jQuery with an Ajax call that looks like this: $.ajax({ type:
I'm having some trouble with IE6 and jQuery UI. I have a popup dialog
I'm facing a trouble with jquery ajax under IE8. I have a form which
I have trouble comparing 2 double in Excel VBA suppose that I have the
I have trouble with the following piece of code. When I go through with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.