Function for range

As the item is passed to your function when running .each, put the innerHeight assignment inside the function as one of the things it does.

I’m no jQuery expert, I’ve learned just enough of it to rip it out of websites being screwed over my it’s mind-numbingly dumbass approach to EVERYTHING, but I think that would go something like this:

$("#myid li").slice(0,3).each(function(li){
	// do your other "each" stuff here

Code (markup):

Though this “innerHeight” assignment junk looks like you’re using JavaScript to control layout. MOST of the time you shouldn’t be doing that in the first place, that’s CSS’ job. Shame jQuery also dupes people into the derpy “functions for nothing” and other overhead inducing derpitude… by that’s why front-end frameworks as a whole amount to little more than … well, see my signature.