Remove white space before comma - Javascript String Operation

Javascript examples for String Operation:String Remove

Description

Remove white space before comma

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from  www  .jav a2  s  . c o  m*/
$('[data-title="Score"]').text(function( index,text ) {
  return text.replace(/ \,/g, ',');
});
    });

      </script> 
   </head> 
   <body> 
      <span data-title="Score">Score: 6-3 , 6-4</span>  
   </body>
</html>

Related Tutorials