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

  • Home
  • SEARCH
  • 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 8589397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:02:54+00:00 2026-06-11T23:02:54+00:00

I have a problem in jQuery, it is that I have an array to

  • 0

I have a problem in jQuery, it is that I have an array to append to an object (id) This function also after intends such as.

When I now use a “each” function in jQuery do I do it this way.

$.each(childrenObj, function(index, value) 
{
    $( document.createElement('ol') )
    .append(
        $( document.createElement('li') )
        .attr('id', 'list_'+ listItem )
        .append(
            $( document.createElement('div') )
            .addClass('listContentItem')
            .html( value.contentTitle )
            )
        )
    .appendTo('#list_'+ ( listItem - 1 ) );

    listItem++;
});

As you would imagine, it will make a <ol><li>test</li></ol> where after doing the same thing over and over again depending on how many people run through.

That I would like is that I would like it to make a <ol> in an object after which I in my each loop adds <li> to it and eventually make a appendTo (‘# id’) after my desire but could not quite get it resolved and it causes some problems pure design front.

Hope there are some who sits with a solution and can help me a little on the road.

  • 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-11T23:02:55+00:00Added an answer on June 11, 2026 at 11:02 pm

    Create the ol outside your loop (below code is untested, but should hopefully work)

    var ol = $( document.createElement('ol') );
    $.each(childrenObj, function(index, value) 
    {
    
        ol.append(
            $( document.createElement('li') )
            .append(
                $( document.createElement('div') )
                .addClass('listContentItem')
                .html( value.contentTitle )
                )
            );
    });
    
    ol.appendTo('#some_id');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to JQuery/Javascript. Have a JSON object that contains an array of strings
Here's my problem, I have a piece of jquery that works fine in modern
Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically
I have a JQuery (using JQuery 1.4.2) problem that exhibits only in IE8 in
I have a problem with Jquery function getJSON, the action url does not trigger
This is a JavaScript/Ajax webpage (also using jQuery). I have a nested structure I
The problem: I have a function that partially works and for some reason it
I have the following scenario jQuery('#content').fadeOut('slow',function(){ jQuery('#content').load(detail.php?product=+imgID+&category=+cat); jQuery('#content').fadeIn('fast'); }); My problem however is that
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have problem to add jQuery to some existing code, please help. We have

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.