How to Remove Comma from String in JQuery?

By Hardik Savani June 14, 2023 Category : jQuery

Sometimes, we require to remove comma, semicolon, colon etc from string in your jquery code At that time you can simply remove comma using js replace(). Jquery replace() through we can replace comma into empty string that way comma will be remove from jquery string.

In this example you can see how it works. It small thing but helpful because this you can also delete semicolon ,colon ,dot etc. So, let's try bellow example and see..

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>

Tags :
Shares