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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:50:52+00:00 2026-06-06T17:50:52+00:00

I am trying to get the ids from some li elements. But I’m not

  • 0

I am trying to get the ids from some li elements. But I’m not sure how to split the results in the array. So message_1 becomes 1, message_2 becomes 2 and so on.

<ul id="chat_viewport">
<li id="message_1">message</li>
<li id="message_2">message this and that</li>
<li id="message_3">3</li>
<li id="message_4">4</li>
<li id="message_5">5</li>
</ul>


<a href="#" class="test">TEST</a>​


$("a.test").click(function(e) {
e.preventDefault();

var idarray = $("#chat_viewport")
         .find("li") //Find the li in #chat_viewport
         .map(function() { return this.id; }) //Project Ids
         .get(); //ToArray

var biggest = Math.max.apply( null, idarray );

alert(idarray);
});​

I have an example here http://jsfiddle.net/T5x5d/

  • 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-06T17:50:53+00:00Added an answer on June 6, 2026 at 5:50 pm

    Replace your .map function with this:

    function() { return this.id.replace('message_', ''); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get my own opinion about this issue but could not,
I'm trying to get unique IDs for object instances in PHP 5+. The function,
im trying to get my jquiz class to count for 2 IDs for each
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying to loop through some elements in a form (radios, text boxes,
I am trying to find a way how to get the twitter ID from
I am trying to make some data from database available using XML, I have
I am using cakephp and trying to pass an array from the view to
I am trying to get assert_select to work on some raw text. Below is
Trying to archive some data from one database table to another over linked server

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.