2019.2

Table Of Contents
results.height( h );
results.width( w );
The following script does the same, but in this case, margins are included.
var h = results.height(true);
var w = results.width(true);
h = h + 20;
w = w + 20;
results.height( h, true);
results.width( w, true);
each()
A generic iterator function, to iterate over the elements in the result set.
each(callback)
Iterates over the elements in a set, such as the enumerable properties of an object, in arbitrary
order. For each distinct property, statements can be executed.
callback
A function. The callback function is passed the iteration index and the current element. In the
scope of the callback function, this refers to the current element.
Examples
The following scripts demonstrate a simple iteration over the elements in the results (the set of
HTML elements that match the selector of the script).
The first script sets the background color of each of the elements to red. (This is just to
demonstrate how this function works. It is easier to change the style of a set of HTML elements
using the css() function; see "Examples" on page1309.)
results.each(function(index){
results[index].css('background-color','red');
});
This script adds a random integer to each element in the result set.
results.each(function(index){
var test = Math.floor((Math.random() * 10) + 1);
Page 1327