How to loop through array in jQuery

0 votes

I am trying to loop through an array. I have the following code:

 var currnt_image_list= '21,32,234,223';
 var substr = currnt_image_list.split(','); // array here

Am trying to get all the data out of the array. Can some one lead me in the right path please?

Jun 23, 2022 in Web Development by gaurav
• 23,260 points
2,231 views

1 answer to this question.

0 votes

Generic loop:

var i;
for (i = 0; i < substr.length; ++i) {
    // do something with `substr[i]`
}

or in ES2015+:

for (let i = 0; i < substr.length; ++i) {
    // do something with `substr[i]`
}
answered Jun 28, 2022 by rajatha
• 7,680 points

Related Questions In Web Development

0 votes
0 answers

How to add a link in Jquery PrettyPhoto to download the image

I am using Jquery PrettyPhoto to have ...READ MORE

Jun 29, 2022 in Web Development by gaurav
• 23,260 points
901 views
0 votes
1 answer

How to Fade In/Out multiple texts using CSS/jQuery like on Droplr?

The jQuery fadeIn() method is used to ...READ MORE

answered Jun 29, 2022 in Web Development by rajatha
• 7,680 points
1,429 views
0 votes
1 answer

How to detect current element id in jQuery?

Use the jQuery attr() Method You can simply ...READ MORE

answered Jun 30, 2022 in Web Development by rajatha
• 7,680 points
822 views
0 votes
0 answers

how to get values of columns for a selected row through jQuery

here i am trying to fetch values ...READ MORE

Jul 1, 2022 in Web Development by gaurav
• 23,260 points
5,429 views
0 votes
0 answers

For-each over an array in JavaScript

How can I loop through all the ...READ MORE

Feb 8, 2022 in Java by Rahul
• 9,680 points
372 views
0 votes
0 answers

For-each over an array in JavaScript

How can I use JavaScript to loop ...READ MORE

Sep 21, 2022 in Java by Nicholas
• 7,760 points
533 views
0 votes
0 answers

Loop over an array in JavaScript

How can I use JavaScript to loop ...READ MORE

Dec 9, 2022 in Java by Nicholas
• 7,760 points
634 views
0 votes
0 answers

how do I create an array in jquery?

$(document).ready(function() { $("a").click(function() { ...READ MORE

Jun 6, 2022 in JQuery by Edureka
• 13,690 points
682 views
0 votes
1 answer

how to use substr() function in jquery?

To get substring of a string in ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
1,264 views
0 votes
1 answer

How to display current element in jQuery?

<! DOCTYPE html> <html> <head> <script> $(document). ready(function(){ $("button"). click(function(){ $("p"). text("Welcome to ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
1,367 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP