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 7794693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:50:56+00:00 2026-06-01T22:50:56+00:00

I am revisiting this code I made a year ago with the help of

  • 0

I am revisiting this code I made a year ago with the help of another person. Unfortunately I don’t have contact with them anymore to get more help. Basically It dynamically adds classs to the tb and b nodes of a document coming from namesToChange. Now what I am trying to do is append some text to the div with class dtxt node but still use this code below. I am using the code $('td.pn_adm_jeff').children('div.dtxt').append('zzz'); and it works but it constantly appends more than once as seen in the photo below. How do I go about making it add once and stop?

Photo
http://img6.imageshack.us/img6/5392/7c23ddb145954aefadb1b9f.png

Code

   function customizefields(a) {
        $('td b').each(function () {
            name = $(this).text();
            if (name.indexOf(" ") != -1) {
                name = name.substring(0, name.indexOf(" "))
            }
            if (a[name]) {
                this.className = a[name].class;
                this.parentNode.className = a[name].img
            }
        })
        $('td.pn_adm_jeff').children('div.dtxt').append('zzz');
    }

    var namesToChange = {
        'Jeff'    :{'class':'pn_adm','img':'pn_adm_jeff'}
    };

    setInterval(function () {
        customizefields(namesToChange)
    }, 1000);

Update

var needsUpdate = true;

function customizefields(a) {
    $('td b').each(function () {
        name = $(this).text();
        if (name.indexOf(" ") != -1) {
            name = name.substring(0, name.indexOf(" "));
        }
        if (a[name]) {
            this.className = a[name].class;
            this.parentNode.className = a[name].img;
        }
    });
    if (needsUpdate) {
        $('td.pn_adm_jeff').children('div.dtxt').append('testing');
        needsUpdate = false;
    }
}

var namesToChange = {
    'jeff'    :{'class':'pn_adm','img':'pn_adm_jeff'};
};

setTimeout(function () {
    customizefields(namesToChange);
}, 1000);
  • 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-06-01T22:50:57+00:00Added an answer on June 1, 2026 at 10:50 pm

    use setTimeout rather than setInterval (interval is for repeating a timer task, timeout is a single timer task)

    To prevent a certain task from occuring more than once in a repeated task, there is a simple fix.

    // global variable
    var needsUpdate = true;
    
    // now in the timer task
    if (needsUpdate) {
        $('td.pn_adm_jeff').children('div.dtxt').append('zzz');
        needsUpdate = false;
    }
    

    Does that work for you?

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

Sidebar

Related Questions

I'm revisiting som old code of mine and have stumbled upon a method for
I'm revisiting an ID scanner station program we built ages ago and I have
I'm revisiting some old code, and have found it doesn't work with jQuery 1.6
I'm revisiting and re-implementing the code that caused me to ask this question about
So I have a code that looks something like this $(.something).live({ mouseover:function(e){ //do stuff
This one has bugged me for a while now. Recently when revisiting some code
I was revisiting pointers when I had this doubt. int *ptr; int arr[5] =
I need some help revising this. It keeps only displaying 0s as the temp.
I came across this line of code in an application I am revising: substr($sometext1
A few months ago I built some online samples like this one from Jeff

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.