Make index method act like jQuery's index.