<html>
<body>
<p>Click the button to alert the string with removed whitespace.</p>
<button onclick="myFunction()">Try it</button>
<p><strong>Note:</strong> The trim() method is not supported in Internet Explorer 8 and earlier versions.</p>
<script>
function myFunction() {
var str = " Hello World! ";
alert(str.trim());
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_trim by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:03:10 GMT -->
</html>