I need to be able to dynamically determine what the index of a certain div inside another div is. For example:
<div id="parent">
<div id="div-0"></div>
<div id="div-5"></div>
<div id="div-1"></div>
<div id="div-2"></div>
<div id="div-3"></div>
<div id="div-4"></div>
</div>
For any of those I need to be able to know if a given div is the first, second etc...
EDIT: Ok obviously I haven't explained this well. I tried all of the below and all I get is 0 every time. I have edited the example above to reflect what is happening. So given the updated example what I need to be able to do is the following:
var index = $('#div-4').index();
Currently this is only returning 0 every time.