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

Using Jquery how to distinguish whether the object value is array or just value..?

In my object loop using the earch function how to find the value as "just a string" - or "array" - or "object" - while loop through..? In case if I find the value as "array" - then i suppose to re-loop the array. But how can i find the value as…
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
1
vote
1 answer

Adding sum of values within nested each loop on resize

I am building a horizontal website that is comprised of a series of sections, floated next to each other in an absolutely positioned WIDE wrapper. Please see diagram below: I need to loop through the contents of each section, add up the widths of…
JCHASE11
  • 3,901
  • 19
  • 69
  • 132
1
vote
1 answer

What would be the best way to convert a object in to separate models

I have a json data, which need to convert in to separate key value pair to add in to a array. what would be the correct way to make the json data into separate key pair data..? I am looking for the best practice. here is my json: { …
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
1
vote
0 answers

Javascript: each function value dynamic title

I am trying to use following code: var list_id = "Cust"; var page_id = "SubPageCust"; var show = "Company"; $.ajax({ url: "sap.php", dataType: "json", type: "POST", success: function(data) { var output…
blason
  • 11
  • 2
1
vote
1 answer

Adding up sum of values within each loop

I created a function which assesses the width of each section, adds them up and then sets the container width to be the sum of all child sections. This works great on page load, but not on resize. Code below: var sunWidth = 0; function…
JCHASE11
  • 3,901
  • 19
  • 69
  • 132
1
vote
2 answers

jQuery adding class to only one anchor instead of all

I have this function: $containing = jQuery('#test a').filter(function(){ return jQuery(this).text().substring(0,2) == "Ba"; }); if ($containing.length > 0) { $containing.first().addClass('testtt'); } This adds the class to the first…
user1770896
  • 159
  • 1
  • 1
  • 11
1
vote
4 answers

jQuery, issue with .each()

I want to reduce every sentence which has more than 3 letters, my code is showing the first 3 letters, then it adds "...", by clicking on these "..." I want to show the whole sentence. But when I'm clicking on every single "..." it reveals every…
user2461031
  • 513
  • 2
  • 7
  • 17
1
vote
1 answer

jQuery - Add class to items based a string with .each() function

I have an online menu that is being generated from a CRM. Each item can be classified by the client within the CRM with one of 3 values. So I have worked out how to get the values and write them into the proper place. What has tripped me up is the…
Archetype
  • 45
  • 1
  • 6
1
vote
2 answers

check all elements against values in an array JQuery

$('.list_body').each(function(){ var job_no = $(this).data('job_id'); if($.inArray(job_no, return_data)) { $.noop(); } else { $(this).closest('div.list_body').remove(); } }); .list_body data-attribute…
Sideshow
  • 1,321
  • 6
  • 28
  • 50
1
vote
1 answer

What's wrong with my .each() function

I created an .getjson() call to work with reddit.com's API. The code is below. $(document).ready(function() { var SEARCH_URL = 'http://www.reddit.com/r/subreddits/search.json?jsonp=?'; var searchQueryText = 'XBox'; …
London804
  • 1,072
  • 1
  • 22
  • 47
1
vote
2 answers

.success not returning xml data correctly in ajax call

I am trying to target elements down three levels in an xml documet. It strangely goes through the each function 13 times but doesn't return anything each time. xml:
Erik Grosskurth
  • 3,762
  • 5
  • 29
  • 44
1
vote
1 answer

jQuery each() finish outer function after the end of iterations

I have a function that needs to loop through all the select tags and the cheackboxes, take their name and value and then assign it to the "data" object. Here's the code data_query:-> data = {} $('input[type="checkbox"]').each -> …
DanielRavina
  • 95
  • 2
  • 6
1
vote
2 answers

JQuery. How to select some cells at each row?

I'm a bit stuck trying to resolve this problem. I need get content of a few cells, and after this do update inner text of this cells For example, I need to get values of cells with class = 2 and class = 4 in each row, and after this, update their…
1
vote
1 answer

Binding two array elements into one

I have a issue which is hurting my head cant think how to do it. I have the following feed. [{ "title": "thumb_36cr8350.jpg", "url": "http://example.com/s3images/thumb_36cr8350.jpg", }, { "title": "large_36cr8352.jpg", "url":…
user1503606
  • 3,872
  • 13
  • 44
  • 78
1
vote
2 answers

Javascript/jquery write each text value from :selected option to separate input

I'm retrieving some data from MySQL and write it in certain select tags, then i retrieve every selected option value and display it in a DIV, here is the javascript: function main() { $("select").change(function () { var str = ""; $("select…
user2272861