jQuery Batch Plugin Demos

There are three example divs, each with their own styles.

There are four ways to get the width of each div in an Array. Notice that the first two return strings because it is using the css method and the last two return numbers becaues it is using the width method.

$('div.batch_example').batch('css', 'width'); // => ["25px", "40px", "15px"]
$('div.batch_example').styles('width'); // => ["25px", "40px", "15px"]
$('div.batch_example').batch('width'); // => [25, 40, 15]
$('div.batch_example').widths(); // => [25, 40, 15]

The following three buttons alerts the results of width, height, or backgroundColor.

Here is the code that is used to hook up the buttons and display the results.

jQuery(function($) {
    var $divs = $('div.batch_example');
    $('#batch_example_width').click(function(event) {
        alert( $divs.widths().join(', ') );
    });

    $('#batch_example_height').click(function(event) {
        alert( $divs.heights().join(', ') );
    });

    $('#batch_example_backgroundColor').click(function(event) {
        alert( $divs.styles('backgroundColor').join(', ') );
    });
});