【发布时间】:2014-11-05 23:35:31
【问题描述】:
我有一些使用 jquery .load 插入的值。我想将这些值加在一起并将结果显示在 div (或 span 或其他)中。这是我用来插入值的代码(数字,但只是纯文本):
结束正文标签上方:我有:
$( "#result1" ).load( "mypage.php?f=15 .threadcount" );
$( "#result2" ).load( "mypage.php?f=16 .threadcount" );
$( "#result3" ).load( "mypage.php?f=25 .threadcount" );
$( "#result4" ).load( "mypage.php?f=18 .threadcount" );
并在页面上方显示这些值:
<div id="result1"></div>, <div id="result2"></div>... etc.
将它们加在一起并显示我尝试使用this answer to "Add values together using jquery"的总数
但这给了我“$NaN”作为我的总价值。我假设是因为它在求和的同时加载该值?或者它无法将 frm .load 中的那段文本识别为数字?
我还尝试更改 this answer to "Dynamically adding the sum of field in Jquery" 答案中使用的代码,该代码在输入表单输入时添加值,但我也没有得到任何结果。
非常感谢您提供的任何建议。
【问题讨论】: