用jQuery删除逗号 [英] Remove Commas with Jquery

查看:350
本文介绍了用jQuery删除逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些从字符串中删除逗号的代码. 我目前在PHP的number_format()中有各种数字. 我使用Jquery将某些内容发布到更新页面,并且需要从类中删除逗号.

I am in need of some code that removes commas from a string. I currently have a variety of numbers in the number_format() for PHP. I use Jquery to post certain things to a update page and I need the commas removed from a class.

例如,这里是一些代码.

for instance here is some code.

<span class="money">1,234,567</span>

我希望发布的代码值为1234567,而不是1,234,567. 如果可能的话,我想使用Jquery.

I want the value of the code I post to be 1234567 instead of 1,234,567. I would like to use Jquery if that's possible.

谢谢

推荐答案

替换

var noCommas = $('.money').text().replace(/,/g, ''),
    asANumber = +noCommas;

这篇关于用jQuery删除逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆