I can’t find this anywhere, how do you check to see if slice is returning elements still in the list? Like $('.class').slice(n-th,n-th);
When n-th variables are increased throughout the index of the return class by slicing, how do you know when slice returns on an invalid index? Hope I explained that well.
Here is the example code of what I’m trying to accomplish:
$(window).scroll(function() {
if(!($('embed').slice(p1,p2).show())){
$(window).unbind('scroll');
}
++p1;++p2;
}
Also, why is my event not unbinding?
Thanks for any assistance 🙂
Simply test
slice().lengthto see if you got anything back, or you can test it for a specificlength.In your case:
In general you want to look at:
The above simply tests for 1+ elements. If you’re slicing off
Nelements and you want to make sure that you get a full and complete result, simply modify tojQuery’s
.slice()never returns things beyond the end of the remaining elements. It’s smart enough to know when to stop.If you give it an end point that exceeds the number of elements, it’ll return the elements that exist, then it’ll stop without a runtime error.