jQuery .each() with Array

Posted by John Crain on Stack Overflow See other posts from Stack Overflow or by John Crain
Published on 2010-06-09T17:07:10Z Indexed on 2010/06/09 17:12 UTC
Read the original article Hit count: 190

Filed under:
|
|

Basically, I am trying to gather the IDs of every element with a specific class and place those IDs into an array. I'm using jQuery 1.4.1 and have tried using .each(), but don't really understand it or how to pass the array out of the function.

$('a#submitarray').click(function(){

    var datearray = new Array();

    $('.selected').each(function(){
        datearray.push($(this).attr('id'));
    });

    // AJAX code to send datearray to process.php file

});

I'm sure I'm way off, as I'm pretty new at this, so any advice help would be awesome. Thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about arrays