Remove All Spaces from String in JQuery?

Have you ever encountered a situation where you need to remove all spaces from a string using JQuery? In this blog article, we will explore the various methods to remove spaces from a string using JQuery.

Step 1:- Create a HTML Page

<html lang="en">
<head>
    <title>How to remove all spaces from string in JQuery? - Wizbrand</title>  
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>


<div>
  <h1>How to remove all spaces from string in JQuery? - Wizbrand</h1>
  <textarea class="content-text">
  	Wizbrand have a 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>

Output:-

Related Posts

Village Opportunity Guide: Simple Farm Habits and Village Business Ideas

Every farming season tells a different story across Indian villages. One month brings early rain, the next brings dry winds, and market rates shift while crops are…

Read More

AI News Aggregator: Navigating Today’s Fast News Cycle

Modern readers deal with a flood of alerts, live blogs, and social posts from dawn to midnight. Instead of feeling informed, most people end up confused or…

Read More

Reclaiming Lost Hours: How Small Businesses Simplify Time, Leave, and Payroll Prep

In a small company, every single hour counts. Yet many founders, team leads, and HR staff lose ten to fifteen minutes several times a day on routine…

Read More

Behind the Scenes of Live Events in India: How Fans Find Shows and Organizers Run Smooth Bookings

Every live show in India has two stories happening at the same time. Out in the city, friends scroll on their phones looking for a fun weekend…

Read More

Smart Vehicle Rentals in Europe: A Complete Handbook for Travelers, Owners, and Fleet Operators

Renting or sharing a vehicle in Europe works best when you know how local rules, pricing, and digital tools fit together. Millions of travelers visit European cities,…

Read More

Renting Cars and Motorcycles in the UAE: A Practical Decision Guide

Imagine planning a weekend ride along the Arabian Gulf coast or organizing business meetings across two emirates in a single day. Buying a vehicle makes little sense…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x