Jquery - 运行 插件转换为 USD $ 后出现 NaN 错误

Jquery - NaN error after running plugin to convert to USD $

$(document).ready(function() {
  $('#clone').click(function() {
    var target = $(this).closest('.groupcontainer');
    target.clone(true, true).insertAfter(target);
  });

  $('.input').on('input',function(){
    $(this).parent().children('.grouptotal').val($(this).val() *  
$(this).parent().children('.input2').val());
  $('.grouptotal').change();
  });

  $('.input2').on('input', function(){
    $(this).parent().children('.grouptotal').val($(this).val() * 
$(this).parent().children('.input').val());
     $('.grouptotal').change();
  });
  $('.input2').dblclick(function(){
    $(this).parent().children('.input2').autoNumeric('init', {aSign: "$ "});
  });  
  $('.grouptotal').dblclick(function(){
    $(this).parent().children('.grouptotal').autoNumeric('init', {aSign: "$ "});
  });
  $('#subtotal').dblclick(function(){
    $(this).parent().children('#subtotal').autoNumeric('init', {aSign: "$ "});
  });
  $('.reset').click(function(){
    $('.behindgroup').parent().children().find('input, textarea').val('');
  });
});  


$(document).on('change', '.grouptotal', function(){
  var sum = 0;
    $('.grouptotal').each(function(){
    sum += +$(this).val();
    });
    $('#subtotal').val(sum);
      });

这是 Fiddle

我有一个函数执行 quantity * system = grouptotal。

我现在的问题是这个。我有一个插件 (autoNumeric),可以将 .grouptotal 转换为美元。但是,当我双击它进行转换时,我的 #subtotal 将从数字变为 NaN。我试过将 parseInt 放在我能想到的每个地方,但在插件 运行 之后它总是恢复为 NaN。在 运行 安装插件之前,#subtotal 没问题,但它们不是我需要的金额。

我已将 sum += +$(this).val(); 更改为 sum += +parseInt($(this).val()) || 0;,但它最终在 #subtotal 中返回了 0。

如何让 #subtotal 在我 运行 我的插件转换为 $USD 后仅从 .grouptotal 中提取数字?

我希望这是有道理的..

使用 JavaScript,您可以通过执行以下操作来利用正则表达式:

 '.00'.match(/\d+/)[0]

小计为“$45.00”。

已找到 here