Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
http://cdpn.io/AafGc
http://codepen.io/jakedx6/pen/AafGc
我以前从来没有真正尝试过在 Jquery 中编写类似这样的代码,我确信我的代码是一团糟,但我希望能得到一些帮助以使其工作。上面的链接指向我的问题的 CodePen。
谢谢!
您正在尝试使用类似的字符串进行计算,$5,000这是不可能的,因为它不是数字 ( NaN)。
$5,000
NaN
如果您删除$char 您的代码按预期工作:
$
var totalcoan = $( "#tviytviy" ).val().substring(1); var totalvfiy = $( "#totalcoan" ).val().substring(1);
我更新了你的代码。
您还应该使用$(this)而不是$("this")因为您想选择对象而不是 DOM 标记this。
$(this)
$("this")
this