Home Javascript How to remove comma from string in jquery ?

How to remove comma from string in jquery ?

by Shahriar Sagor

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.

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

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


You may also like