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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:14:42+00:00 2026-06-07T20:14:42+00:00

Trying to append a div to another using the following function customizefields , but

  • 0

Trying to append a div to another using the following function customizefields, but i’m not successful. The console returns no errors so I don’t know where to go from here?

javascript

function customizefields(objNames) {
    $('td div').each(function(){
        name = $(this).text();
        if (name.indexOf(" ") != -1) {
            name = name.substring(0, name.indexOf(" "));
        }
        if (objNames[name]) {
             $('<div/>', {
                  id: 'bio',
                  text: objNames[name].bio
             }).appendTo(this);
        }
    });
}

var namesToChange = {
    'Ben':{'class':'pn_cool','bio':'some text for ben'},
    'Andrew':{'class':'pn_bad','bio':'some text for andrew'}
};

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

html

<tr>
   <td class="stxt2">
      <img src="#" class="pic">
      <div class="dtxt2" title="07/10/12 09:40 PM">40 mins ago</div>
      <b class="nme pn_usr">Andrew</b>: Ut lacus sapien, pretium ut dictum eget, tempus ac nisi.
   </td>
</tr>
<tr>
   <td class="stxt">
      <img src="#" class="pic">
      <div class="dtxt" title="07/10/12 09:30 PM">30 mins ago</div>
      <b class="nme pn_usr">Ben</b>: Cras vitae cursus lectus.
   </td>
</tr>
<tr>

The results I am trying to achieve

    <tr>
       <td class="stxt">
          <img src="#" class="pic">
<div id="bio">TEXT FROM OBJECT WILL GO HERE</div>
          <div class="dtxt" title="07/10/12 09:30 PM">30 mins ago</div>
          <b class="nme pn_usr">Ben</b>: Cras vitae cursus lectus.
       </td>
    </tr>
<tr>
  • 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-07T20:14:44+00:00Added an answer on June 7, 2026 at 8:14 pm

    It seems to me you should be looking at the textual content of the sibling b tag, not, as currently, the div tag.

    Currently, for example, the value of your name var (which, by the way, is global) would be ’40’ and, for the next iteration, ’30’.

    Presumably you meant

    $('td div').each(function() {
        name = $(this).next('b').text();
        //more code...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div that is created by Ajax with .append(html) function, I'm trying
I am trying to use the .append function in jquery. I have a div
When trying to append one div to another Im finding that this doesn't work:
I am am trying to append an element to a <div> of a page,
I am trying to dynamically append some objects to a div and then programatically
I'm trying to append a CSS class to a row on RowDataBound. I'm using
I am trying to append to a log file, using HTML tables format for
I'm trying to add another one of these on an image click: <div class=roleoption>
I'm using jQuery 1.5.2 trying to dynamically load a div from one source into
I am trying to append a table row with an ID to another table.

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.