What am I missing regarding JQuery's index() method. Based on the documentation, I would expect to be alerted a value of 1 here:
HTML
<div class="test" id="div1"></div>
<div class="test" id="div2"></div>
JS
$(document).ready(function(){
var index = $('.test').index('#div2');
alert(index);
});
Here's a fiddle: http://jsfiddle.net/cpody1cb/
Why am I alerted -1? If I instead use index('#div1'), I am alerted 0, as I would expect.
$('#div2').index('.test')