[Solved] What does -1 index of an element mean?


-1 means the object cannot be found in the array.

$cart.index() returns -1, hence whatever is in $cart can not be found. One line above, you assign $('.cart:eq(' + cartIndex + ')') to $cart. Hence the selector .cart:eq(' + cartIndex + ')' matches no element in your html.

solved What does -1 index of an element mean?