How to remove all whitespace from string in JQuery?
Sometimes we require to remove white space from given string. So at that time you can delete spaces from string using replace() of core php. replace() will help to replace your blank space or empty space or extra space or trailing space from string that way we can remove. you can do it from bellow example.
Example:
<html lang="en">
<head>
<title>Jquery - Remove white space from string</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<div class="mytext">
This is my site.
</div>
<script type="text/javascript">
var myText = $(".mytext").text();
var newMyText = myText.replace(/ /g,'');
alert(newMyText);
</script>
</body>
</html>

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.