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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:11:23+00:00 2026-05-28T06:11:23+00:00

Let’s say we have the following html: <ul id=portfolio-list class=clearfix span-24> <li class=2012#foo bar

  • 0

Let’s say we have the following html:

 <ul id="portfolio-list" class="clearfix span-24">

  <li class="2012#foo bar car#cat_1">item 1 <br /></li>
  <li class="2011#car foo fly#cat1">item2 <br /></li>
  <li class="2009#car fly swat_car#cat_2">item3<br /></li>
  <li class="2012#bar show car#cat_3">item 4<br /></li>

</ul>

and I want to create a map the classes each item to do the following:

  1. I’m trying to split the code into three parts
  2. output each piece and
  3. add them to their own array of values.

Using the following code, it only returns the value from the last list item.

How do I get it to iterate over ALL the list items and add the values for each list item.

code follows:

jQuery(document).ready(function($) {
    var splitList = $("#portfolio-list li").map(function() {
        inStringy = $(this).attr("class").split('#');
        list = $(this).attr('class');
        list = list.split("#").join(" ");
        $(this).removeClass();
        var that = $(this);
        $(that).addClass(list);
        return inStringy;
    });

    cla = [];
    yr = inStringy[0]; 
    classListin[classListin.length] = cla + "";
    categoryListin[categoryListin.length] = cat + " ";
    cla = inStringy[1];
    cla = cla.split(" ");
    cat = inStringy[2];
    yearListin = [];
    classListin = [];
    categoryListin = [];
    yearListin[yearListin.length] = yr + "";
    classListin[classListin.length] = cla + "";
    categoryListin[categoryListin.length] = cat + " ";
});

Any help would be appreciated!!!

  • 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-28T06:11:24+00:00Added an answer on May 28, 2026 at 6:11 am

    Globals all over the place!
    See comments for explanations.

    // answer moved to fiddle:
    http://jsfiddle.net/VyFc8/

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

Sidebar

Related Questions

Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have the following classes : public class MyProductCode { private String
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have this HTML: <div> <div class=ClassA></div> <div class=ClassX></div> <div class=ClassB></div> <div
Let's say we have the following: abstract class A; class B : public A;
Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option

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.