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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:36:25+00:00 2026-05-23T01:36:25+00:00

I would like to replace abcName with xyzName ? <tr> <td> <b class=abcName>Bob</b> </td>

  • 0

I would like to replace abcName with xyzName?

<tr>
    <td>
        <b class="abcName">Bob</b>
    </td>
</tr>

Using this, but on page load nothing changes:

var bobo = document.getElementsByTagName("td");


function user(a, b, c) {
    try {
        if (bobo[c].innerHTML.match('>' + a)) {
            bobo[c].className = b;
        }
    } catch (e) {}
}


function customs() {
    for (i = 0; i < bobo.length; i++) {

        classChange("Bob", "xyzName", i);

    }
}
setInterval("customs()", 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-05-23T01:36:26+00:00Added an answer on May 23, 2026 at 1:36 am

    Although I’m not real sure if what you’re doing with the interval and whatnot is the best approach, you can:

    var tidi = document.getElementsByTagName("td");
    
    function changeStyleUser(a, b, c) {
        try {
            if (tidi[c].children[0].innerHTML.indexOf(a) === 0) {
                tidi[c].className = b;
            }
        } catch (e) {}
    }
    
    
    function customizefields() {
        for (i = 0; i < tidi.length; i++) {
    
            changeStyleUser("Bob", "xyzName", i);
    
        }
    }
    setInterval("customizefields()", 1000);
    

    http://jsfiddle.net/zBmjb/

    Note, you also had the wrong function name in your for loop as well.

    If you use jQuery, this would be MUCH simpler.

    EDIT

    Using jQuery:

    function customizefields(a) {
        $('td b').each(function(){
            if ($(this).text().indexOf(a) === 0) {
                this.className = 'xyzName';
            }
        });
    }
    setInterval(function(){customizefields('Bob')}, 1000);
    

    http://jsfiddle.net/zBmjb/1/

    Also, note the use of the anonymous function instead of using a string in setInterval(). This allows you to not use eval(), which is considered expensive and potentially harmful.

    EDIT 2

    If you wanted to pass in a list of name and class associations, you could use an array with objects, like so:

    function customizefields(arrNames) {
        $('td b').each(function(){
            for (var i = 0; i < arrNames.length; i++) {
                if ($(this).text().indexOf(arrNames[i].name) === 0) {
                    this.className = arrNames[i].class;
                }
            }
        });
    }
    var namesToChange = [
        {'name':'Bob','class':'Bob'},
        {'name':'Bert','class':'Bert'},
        {'name':'Jeff','class':'Jeff'}
    ];
    setInterval(function(){customizefields(namesToChange)}, 1000);
    

    http://jsfiddle.net/zBmjb/4/

    It feels messy though, since it searches for all selected nodes, then for each found, loops over the current node for each name looking for a matched value, all while doing this once a second. The cleaner approach would be to see if the name value from the current node was found:

    function customizefields(objNames) {
        $('td b').each(function(){
            name = $(this).text();
            if (name.indexOf(" ") != -1) {
                name = name.substring(0, name.indexOf(" "));
            }
            if (objNames[name]) {
                this.className = objNames[name];
            }
        });
    }
    var namesToChange = {
        'Bob':'Bob',
        'Bert':'Bert',
        'Jeff':'Jeff'
    };
    setInterval(function(){customizefields(namesToChange)}, 1000);
    

    http://jsfiddle.net/zBmjb/5/

    EDIT 3

    If you need multiple values, you can make the value for the object an object as well.

    function customizefields(objNames) {
        $('td b').each(function(){
            name = $(this).text();
            if (name.indexOf(" ") != -1) {
                name = name.substring(0, name.indexOf(" "));
            }
            if (objNames[name]) {
                this.className = objNames[name].class;
                this.style.backgroundImage = "url(" + objNames[name].img + ")";
            }
        });
    }
    var namesToChange = {
        'Bob':{'class':'Bob','img':'bobspic.jpg'},
        'Bob':{'class':'Bert','img':'Bertphoto.jpg'},
        'Bob':{'class':'Jeff','img':'jeff.jpg'}
    };
    setInterval(function(){customizefields(namesToChange)}, 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to replace only the group in parenthesis in this expression :
I'm using jQuery with the validators plugin. I would like to replace the required
I have a pipe delimited string like this: blah|blah|blah|blah|blah|blah|blah|blah|blah|oldDate|blah|blah| I would like replace the
I would like to replace the default malloc at link time to use a
I would like to replace the entire header area in an NSIS installer with
In Eclipse 3.3.2, I would like to replace a character (say ',') by a
I would like to write a macro for Notepad++ which should replace char1, char2,
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to sort an array in ascending order using C/C++ . The
I have a UIImage with white background. I would like replace the white background/pixels

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.