remove space from the middle string in jquery code example Example: javascript remove all spaces from string str = str.replace(/\s/g, '');