how to trim string only after word end jquery code example Example: trim space in jquery var str = " Hello World! "; alert(str.trim());