Thursday, 5 September 2013

Prototype equivalent of jQuery eq method

Prototype equivalent of jQuery eq method

Given the following html code:
<ul id="fun">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
</ul>
I can select the third li in jquery like so:
$('#fun li').eq(2);
In prototype I know I can do something like :
$("fun").select('li').each(function(i,v){
if(v == 2){/*do whatever*/}
});
So what I'm asking is does prototype have a method like jquerys eq that
allows you to select a particularly indexed element in an array of
elements?
Thanks

No comments:

Post a Comment