I want to make different background color for ul children depending on their orders, how can I get the order of children using jquery.
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
<li>f</li>
</ul>
$('ul li').bind('mouseover', function(e){
//how can I get the order of the childre
//when hover on c it shoul returns 3
alert("child order ");
});
here's an example http://jsfiddle.net/sHefJ/
For that subset of HTML, using...
$(this).index() + 1
...would be sufficient.
I added 1
because your numbering system in your example doesn't appear to be 0
based.