How to remove comma from string in jquery ?

Today now in this post i will show you How to remove comma from string in jquery ? Sometimes, we may need to remove the comma, semicolon, colon etc from the string in our jquery code. So at that time we can do this simply remove comma by using js replace(). Jquery replace() through we can easily replace the comma into empty string on that way comma will be remove from the jquery string.

So In this example we can see how it is works. It is very small thing but it is helpful because this we can also delete semicolon ,colon ,dot etc. So, let’s try by using bellow example.

Example:
<html lang="en">
<head>
  <title>Jquery remove comma from string</title>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
    $(document).ready(function() {
      var myStr = "Hi, Hardik. How are you?";
      myStr = myStr.replace(/,/g, "");
      alert(myStr);
    });
</script>
</body>
</html>

Read Also: How to Add remove input fields dynamically using jquery with Bootstrap?

Thanks for read. I hope it help you. For more you can follow us onĀ facebook

close

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →