【问题标题】:Keep a running total [closed]保持运行总计[关闭]
【发布时间】:2013-07-25 18:44:15
【问题描述】:

我的应用中有一个项目列表,其中包含单选按钮。当我更改单选按钮上的设置时,我想更新页面底部的运行总计。如何设置运行总计?

【问题讨论】:

  • 你所说的“运行总数”是什么意思?单选按钮被填充的项目数?
  • 这个问题与那个代表有关?

标签: javascript jquery-mobile


【解决方案1】:

这有一些缺陷,但它应该让你开始:

<html>
<head>
<script>
    var total = 0;
    function count(input) {
        if(input.checked) {
            total++;
        }
        document.getElementById('total').innerHTML = total;
    }
</script>
</head>
<body>
    <input type="radio" id="radio1" onclick="count(this);"/>Radio 1

    <span id="total">0</span>
</body>
</html>

【讨论】:

  • 我一直在试图找出一个在 jquery mobile 中使用的控件。我从来没有想过使用innerHTML。谢谢。
猜你喜欢
  • 1970-01-01
  • 2019-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多