I'm trying to get the index of an element within an array returned by a jquery selector.
Here's my code:
$("div").click( function(){
alert( $.inArray( $(this), $("#div") ) );
});
An an example, for this HTML:
<div>A</div>
<div>B</div>
<div>C</div>
<div>D</div>
I want it to display "4" when the user clicks the div containing D. Is there any way to do this? This inArray function doesn't seem to do what I expect when applied to selectors.