How to Remove All Whitespace from String in JQuery?

By Hardik Savani November 5, 2023 Category : jQuery


In this quick guide, we will teach you jquery remove all whitespace from string. If you have a question about remove space from string jquery then I will give a simple example with a solution. We will use jquery remove whitespace from string. In this article, we will implement a remove whitespace from string using 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.



<html lang="en">


<title>Jquery - Remove white space from string</title>

<script src=""></script>



<div class="mytext">

This is my site.


<script type="text/javascript">

var myString = "This is my site.";

var newString = myString.replace(/ /g,'');







I hope it can help you...

Tags :