How to select a range of elements in jQuery

jQuery slice() function taking indexes of the first and the last needed elements selects a subset of the matched elements. Note what it doesn’t include last element itself.

In your particular case you should use

$("#myDiv a").slice(1, 4)

Leave a Comment