I'm checking to see if element is last in the container div by getting length on next element with class .item
(if there is such element, it means that I am currently not at the end of the container div)
if($(this).next('.item').length < 1) {
console.log('element is last');
}
In case if it is last, I want to move it up, i.e insert it before previous .item
so it now becomes second last.
I looked into .insertBefore()
, however I don't explicitly know which "before" element to target.