从Jquery中的字符串中删除所有逗号

ina*_*naz 2 html javascript css jquery

我有很多课程,如果有任何逗号,我想删除它们中的逗号.

我写了下面的代码,但代码无法正常工作.第二个类值替换为第一个值.

   
var removebox = $(".remove"),
removeboxHtml = removebox.html();
removebox.html(removeboxHtml.replace(/,/g , ''));
Run Code Online (Sandbox Code Playgroud)
<html>
  <head>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
  </head>
  <body>
    <span class="remove">,17500000</span>
    <span class="remove">,2479000</span>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Kin*_*iri 10

试试这个.更新了您的代码:

   

$(".remove").each(function(){
   
    $(this).html($(this).html().replace(/,/g , ''));
});
   
Run Code Online (Sandbox Code Playgroud)
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
</head>
<body>
<span class="remove">,17500000</span>
<span class="remove">,2479000</span>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)