how iterate between divs jquery
<p>i have doubt about how can i iterate into a group of div, my problem it's that i have this selector</p>

<pre><code>$('.imagePanel')
</code></pre>

<p>this selector give a  group of div that belong's to that class. Also i know that with the method <code>length</code> i can know how divs are. the problem it's that i wanna know if i can storage in a array each div to know what's it's the div which it's clicking by the user in other words to this</p>

<pre><code>$(".imagePanel").click(setElement);

function setElement() {

for (var i = 0; i &lt; $('.imagePanel').length; i++) {

    //validate in the loop if it's in the div that click the user
    if (this.id == $("#"i).id) {

        if (!$(this).data('selected')) {
            $(this).css('border', '2px solid black').data('selected', true);
        }
        else {
            $(this).stop(true, true).data('selected', false);
        }
    }

}
}
</code></pre>

<p><strong>edit</strong></p>

<p>to see more clear. in the group of div i need that only one have the style, if you click in one an then in other, the last div that you make the click it's the one with the style the other div's need's to clear the style    </p>

<p><strong>don't want this</strong></p>

<p><img src="http://i.stack.imgur.com/6zhTZ.png" alt="enter image description here"></p>

<p>thanks for your time</p>
