Fix jQuery #13251: use slice instead of substring
(cherry picked from commit 37eb6125c0fb0bec4e0d043bc78110b4f49f3aa6)