How to remove spaces from string using JQuery?
In this post we will show you How to remove spaces from string using JQuery, hear for How to remove spaces from string using JQuery we will give you demo and example for implement.
In this post, we would like to share with you how to remove all white spaces or blank space from a string using jquery.
Actually, we may sometime require to delete all empty spaces from string using jquery javascript. we can easily remove all black space using jquery replace function.
Here we give you very small example with one rich textbox and add button bellow. You have to simple add string on rich text box then click on button it will remove spaces from added string.
It’s very simple example and also we give you demo for this you can see bellow button. You are able to download code for remove spaces using jquery. So let’s see bellow example.
Example – jquery remove space between words
<html lang="en"> <head> <title>How to remove spaces from string using JQuery? - infinityknow</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script> </head> <body> <div> <h1>How to remove spaces from string using JQuery? - infinityknow</h1> <textarea class="content-text"> collection of Example and Demo of IT. </textarea> <button>Remove White Space</button> </div> <script type="text/javascript"> $("button").click(function(){ myText = $(".content-text").val(); var remove_space = myText.replace(/ /g,''); alert(remove_space); }); </script> </body> </html>
Hope this code and post will helped you for implement How to remove spaces from string JQuery. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section.