I need to loop through a selection of elements and need to do things for all elements not first or last in the selection.
I’m having problems getting my selector to work:
var set = $('.someElements')
setLen = set.length;
if (setLen > 2 ) {
set.not(setLen.first(), setLen.last() ).addClass('someClass')
}
Can somebody point me to the correct way of selecting the “middle elements”?
Thanks!
As you only want to remove elements from the beginning and the end of the set, you can simply use
.slice[docs]: