Questions tagged [each]

An iterator function or language struct which can be used to iterate over arrays or lists.

A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.

jQuery.each( array, callback )
// or
jQuery.each( object, callback )
3858 questions
1
vote
2 answers

jquery Looping (.each)

I have an object that looks like the following: Node{ name: "root", level: 0, children: Array[14], parent: null, id: 0 } And inside Node.children... Node.children[ { name: "child1", level: 1, children:…
user2415131
  • 95
  • 3
  • 9
1
vote
1 answer

jQuery return value of .each function in an .each function

Okay.. this is a bit hard to explain, and I was not sure how to call the title. Anyway I made a fiddle to make it more clear: see this fiddle What do I want? I'm working on a Wordpress plugin, and what you see in the Fiddle would be a function in…
Trekdrop
  • 475
  • 7
  • 27
1
vote
3 answers

Restart jQuery.each() after loop ends

I have array of values and i want to set those values as placeholders to my input. How to achieve this using jQuery.each() only because i solved my issue with this solution and it works perfectly. I tried doing this to restart it but it's not…
Charaf JRA
  • 8,249
  • 1
  • 34
  • 44
1
vote
2 answers

jQuery .each problem

Brain squeeze and need help, I have a table with 6 rows that are that can be hidden or visible depending on if a check box is checked. This .each routine works great with one small problem - when the last check box (val="5") is checked and you hit…
Bob Knothe
  • 285
  • 1
  • 4
  • 11
1
vote
3 answers

Ruby custom iterators

I have a class game which contains some arrays of custom objects (dinosaurs, cacemen etc.), that are returned by different accessors, such as game.dinosaurs, game.cavemen etc. At present, all these accessors just return the internally stored arrays.…
SasQ
  • 14,009
  • 7
  • 43
  • 43
1
vote
2 answers

grails - print each row's value with column name from GroovyRowResult

I want to let a user fire sql query and then see the result in grails view page. My QueryController.groovy is def query(){ def headers = null; //["id","name"] Sql sql = new Sql(dataSource) def rowResults = sql.rows(params.query)…
prayagupa
  • 30,204
  • 14
  • 155
  • 192
1
vote
4 answers

Adding array together with nil as a possibility

I am creating a method that will take an array of numbers and add them together. I don't want to use inject because I haven't learned it yet. I prefer to start with the basics. I want to use either each or while. I've been re-writing this code and…
1
vote
1 answer

changing the values on a hash function

I'm going through the RubyMonk exercises on hashes The exercise is to change the prices of the restaurant_menu by 10%. My solution was incorrect. I iterated over each tuple and changed just the price value. restaurant_menu = { "Ramen" => 3, "Dal…
jingyang81
  • 453
  • 1
  • 4
  • 7
1
vote
3 answers

Get id and text from all elements with class and put into JSON array

I'm doing a each function for all elements with a spesific class, but here it only fetches the last one, and not putting all of them into the JSON-array. JS fiddle here: http://jsfiddle.net/MYGCM/1/ Here is the HTML:
Kim
  • 1,128
  • 6
  • 21
  • 41
1
vote
3 answers

How to use jQuery each() to parse items loaded

I have a big page with a "load more" button at the bottom; each click on "load more" loads more content via AJAX. Part of that content is Facebook like and comment buttons:
Eric
  • 5,104
  • 10
  • 41
  • 70
1
vote
1 answer

.each() makes the page Freeze

The idea is to fetch the content from an external PHP file on Page load using jQuery .each() function. The problem is the page freezes or keeps on loading and never ends. What would be the issue? PHP Page
Sarvap Praharanayuthan
  • 4,212
  • 7
  • 47
  • 72
1
vote
2 answers

Uncaught TypeError: Object [object Window] has no method 'each' function

Hey guys here is my js file and I am taking error message about each function at line:24 and I do not know why I couldnt find whats wrong. I am just trying to see the list of items on the console.log panel but it does not even give me list on the…
mergul
  • 19
  • 6
1
vote
2 answers

ruby - if string is not contained within an array

I only want to output one anchor here. If the current_page is in the array I get two (.html and -nf.html). If it is not in the array I get as many anchors as there are items in the array. I am using StaticMatic. - if page_options[:current_index] <…
Dr. Frankenstein
  • 4,634
  • 7
  • 33
  • 48
1
vote
5 answers

Javascript: Each Array

Note: No jQuery How could i do something like this: var array = new Array(); array[name] = "Tom"; array[age] = 15; foreach(array as key=>value){ alert(key + " = " + value); }
tarnfeld
  • 25,992
  • 41
  • 111
  • 146
1
vote
2 answers

jquery - find an attribute value?

I have a series of containers containing map data and links. Im using jquery to cycle through those containers to get certain data. In this situation im trying to get an attribute of a link. I use the following jquery to get all of the html of each…
Sam Healey
  • 666
  • 2
  • 8
  • 22