how to remove all characters from a elements accept the last to in javascript code example Example: remove last 3 characters from string javascript str = str.slice(0, -3);