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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:14:37+00:00 2026-05-24T13:14:37+00:00

Currently in my JQuery script I have a hard coded array: var arrayList =

  • 0

Currently in my JQuery script I have a hard coded array:

var arrayList = [
    {"id":"1","category":"foo1","title":"bar1","image":"images/foobar1.gif"},
    {"id":"2","category":"foo2","title":"bar2","image":"images/foobar2.gif"},
    etc....
];

Instead of that array being hard coded in my script I need to create that dynamically from a set of HTML unordered lists that are generated from the system so the markup would be:

<ul>
    <li>1</li>
    <li>foo1</li>
    <li>bar1</li>
    <li>images/foobar1.gif</li>
</ul>

<ul>
    <li>2</li>
    <li>foo2</li>
    <li>bar2</li>
    <li>images/foobar2.gif</li>
</ul>

etc….

I would need:

var arrayList = new Array (that has been created)

How can I do this so that a new array object is created and it doesn’t just see the output as a text string?

  • 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-24T13:14:39+00:00Added an answer on May 24, 2026 at 1:14 pm

    Try this.

    var items = [];
    $("ul").each(function(){
        var item = {};
        var lis = $(this).find("li");
        item.id = lis.get(0).innerHTML;
        item.category = lis.get(1).innerHTML;
        item.title = lis.get(2).innerHTML;
        item.image = lis.get(3).innerHTML;
        items.push(item);
    });
    
    var DTO = JSON.stringify(items);
    

    items will hold the array of your associative objects and DTO will hold the JSON string of that array.
    Choose whatever you need.

    Demo: http://jsfiddle.net/naveen/yA54G/

    P.S: Please add reference to json2.js for browsers that do not have JSON support ( if you use JSON.stringify )

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

Sidebar

Related Questions

Currently I have this JQuery script var img = $(this); img.wrap('<div class=photo></div>'); img.parent().append(<p> +
I currently have a jQuery function that replaces an image when clicked. For instance:
I currently have a single jQuery script page that I include in my ScriptManager
I currently have the following JavaScript/jQuery script that gets an external html page using
Currently I have a JQuery script in place http://jsfiddle.net/gaby/zzj7E/5/ which handles the requirement that
I'm currently using a small jquery script to rotate through background images on a
This is the js code that i have currently <script src=jquery.js type=text/javascript></script> <script type=text/javascript>
I have the following jQuery script... $(function() { $('.eventWrapper').bind('click', function(event) { var srvName =
I'm currently working on a jQuery script that will translate the site's text into
I am working on a AJAX/jquery notification script. Currently it retunrs a whole fhtml

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.