将输入名称为“”的所有值相加;TotalInline[]”;
Add all values with input name="TotalInline[]"
本文关键字:TotalInline 输入 更新时间:2023-09-26
如何从名称为name="TotalInline[]"
的所有输入中添加值?
以下内容不起作用:
var total = 0;
$.each('input[name="TotalInline[]"];,function() {
total += this;
});
这应该有效:
var total = 0;
$('input[name="TotalInline"]').each(function() {
// assuming you have ints in your inputs, use parseFloat if those are floats
total += parseInt(this.value, 10);
});
var total = 0;
$.each($('input[name="TotalInline[]"]'), function() {
total += parseInt(this.value, 10);
});
您有一些严重的语法错误,请尝试以下操作:
var total = 0;
$('input[name="TotalInline[]"]').each(function () {
total += parseInt(this.value, 10);
});
这样尝试。。。
var total = 0;
$('input[name="TotalInline[]"]').each(function() {
total += parseInt($(this).val(),10);
});
var total = 0;
$('input[name="TotalInline[]"]').each(function() {
total += +this.value.replace(/[^'d.]/g, '');
});
- 使用快速正则表达式只过滤掉数字(和小数点)
- 使用
+
前缀转换为数字
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 可以't让我的if语句处理js中的html表单输入
- 名称输入的索引
- 如何编写HTML输入的JS内联
- 要求输入在数据列表中
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 如何将输入(type=text)从html表单传递到javascript函数
- 单击jquery清除输入值
- 而循环只设置php中输入字段中的第一个值
- 在输入字段中将最小金额设置为
- jQuery自定义验证比较多个输入的序列
- Sails.js:同时发布文本输入和一个文件
- 使用javascript检查多个输入值,并在1次检查中标记多个输入框
- 如何在输入字段中的按钮的帮助下打开日历,该字段的类型为“=”;日期”;
- 使用jquery在单击时在单元格中输入值
- Ajax文件加载和<输入>文件加载
- 是否可以将一个函数输入连接到另一个函数调用的文本
- 将值输入到对象,然后该对象推送到数组
- 将输入名称为“”的所有值相加;TotalInline[]”;