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
3 answers

Hide some elements in a html node depending on content

I would like to hide some childrend elements of a div that have some specific values: Lets say we have this structrure :
Mehdi
  • 2,263
  • 1
  • 18
  • 26
1
vote
2 answers

Assign an event handler to all elements of an array without using for or each (jQuery)

I know I can assign an event handler to an html element or class so that if new elements are loaded dynamically the event will still fire to the new added elements. For example: $('#main').on('click','a.link_class', function () { // ... }); I…
Alvaro
  • 9,247
  • 8
  • 49
  • 76
1
vote
1 answer

JQuery - Loop through dynamic elements on custom event

I have hit a bit of a brick wall here. The previous developer on my current project decided to construct the entire front facing portion of this app using one behemoth JS file, with almost no html being used for the page structure at all. So…
Ryan McCoy
  • 484
  • 1
  • 7
  • 11
1
vote
3 answers

jQuery each and indexing elements

So I'm trying to get the number of the li that I click and show the corresponding page text while hiding the others. (labeled #text1, #text2, #text3 etc...), but the code below isn't doing anything for me. Help is greatly appreciated! var…
jaruesink
  • 1,205
  • 2
  • 14
  • 24
1
vote
3 answers

How to return a value from $.each(...)?

To intercept a gazillion of close-votes, I can stress that it's not related to, let alone answered by, this thread. I'm not sure how to return a value from a $.each(...) construction to the outer scope. Suppose that we have an array of JSON objects…
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
1
vote
1 answer

variable not being assigned correctly, possible scope issue (a function with a switch within each() within getJSON())

I have a variable that contains an image path. Depending on what integer value I receive for a JSON object, this variable is supposed to get a different path. However, for some reason within the function below, the path assigned to the variable…
LazerSharks
  • 3,089
  • 4
  • 42
  • 67
1
vote
5 answers

Uncaught TypeError: Cannot set property '0' of undefined

I keep getting Uncaught TypeError: Cannot set property '0' of undefined, but I can't for my life figure out what is wrong! var anchor = []; getAnchors(); function getAnchors() { $('.anchor').each(function(i) { anchor[i] =…
AKG
  • 2,936
  • 5
  • 27
  • 36
1
vote
2 answers

incremental number using jQuery .each()

How do I increment up to a specific number (3), then have it reset, looping back to the first number. The first number should begin at 1 (not 0). I've tried using: i=1; i<=3; i+=1 Here's my basic code: $(document).ready(function() { …
Mikel
  • 117
  • 11
1
vote
2 answers

Difference between applying a function to a class or through each()

Does it make any difference applying a function to all elements that have a class or doing it through the each function? It might be a silly question but in my case a could perform the code in two different ways so I would like to know if there is…
Alvaro
  • 9,247
  • 8
  • 49
  • 76
1
vote
1 answer

.each( ) Function Not Producing Unique Values

I have a bunch of blocks that I'm trying to have move along a square 'track', like a train. var itemLoop = function(){ $("li").each(function(getLeft, getTop) { getLeft = parseInt($(this).css('left')); getTop =…
C_K
  • 1,243
  • 4
  • 18
  • 29
1
vote
1 answer

Insert SVG elements into HTML tag with jQuery

I have two SVG elements, my markup: i need to insert them into tag and in output watch…
Lukas
  • 7,384
  • 20
  • 72
  • 127
1
vote
1 answer

How to add the same atributes for all SVG elements

I have two SVG elements: and i want add for them the same cx and cy atributes, so i use each with jquery but i…
Lukas
  • 7,384
  • 20
  • 72
  • 127
1
vote
4 answers

Ajax Call inside a each() Loop not being asynchronous

What I'm trying to do involves going through a series of checkboxes. For each one of them that it is checked, I have to perform some calculations (using an ajax call). If there is an error, I have to break the loop and return a message. Every ajax…
Antonio Louro
  • 528
  • 1
  • 5
  • 14
1
vote
1 answer

JQuery $.Each() function to get an array of duplicates

I am trying to write a jquery $.each() function that takes in an array and puts the duplicates from that array into another array. I know how to do it using a for loop as seen below, but can't seem to figure it out in an $.each function. Any help…
Sxkaur
  • 235
  • 2
  • 10
1
vote
2 answers

$.each inside $.append (Object [object Array] has no method 'apply')

I am trying to $.append dynamically constructed elements inside a dynamically constructed element inside of a custom plugin: $('
').append( function(){ $.each(paramaterObject.rows, function(rowKey, rowValue){ return…
user1382306
1 2 3
99
100