jQuery function to reverse the matched elements