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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:08:19+00:00 2026-05-29T06:08:19+00:00

i have a problem, i’m working with jquery and some ajax requests. i’m getting

  • 0

i have a problem, i’m working with jquery and some ajax requests.

i’m getting a string like: 5 12 6 8

now i want to split this string into 5,12,6,8 and then add the numbers to some elements like:

$("#l1").html("5");
$("#l2").html("12");
$("#l3").html("6");
$("#l4").html("8");

the problem is, that there are not always 4 numbers, sometimes 8, other times just one. when there is just one it would be:

$("#l1").html("x");

x should be the number which i get.

how to resolve this with jquery?

  • 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-29T06:08:19+00:00Added an answer on May 29, 2026 at 6:08 am

    Assuming that str is a string that looks like “5 12 6 8”:

    $.each(str.split(' '), function(i, val) {
        $('#l'+(i+1)).html(val);
    });
    

    Fiddle: http://jsfiddle.net/Sxucs/1/

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

Sidebar

Related Questions

I have problem with php's preg_match.I want to make something like this : When
i have problem with jquery submit and post. I would like to submit a
I have problem with Razor syntax and jQuery, I'm trying to append some items
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have problem with encoding data in Oracle database. I want to xor string
I have problem in generating or getting decimal value in python. for now, I
I have problem with pointers. This is working fine - int main(void){ char *w;
I have some data like this: 1 2 3 4 5 9 2 6
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names

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.