jQuery - 获取总计取决于选择哪个复选框 [英] jQuery - Getting total depending on which checkboxes are selected
问题描述
我有一系列的复选框代表各种食物。我想创建一个小计取决于用户选择什么。我一直在通过jQuery文档,我看到如何更新一个文本框的值,但是如何做一个新的计数每次一个新的复选框检查。此外,当复选框为未选择时会发生什么。有没有办法在复选框的HTML代码中存储每个项目的值?
我有一个jsFiddle的例子我一直在这里愚弄...
将价格添加到复选框和计数 value
它。这是: http://jsfiddle.net/fQTUp/9/
I have a series of checkboxes that represent various food items. I would like to create a subtotal depending on what the user selects. I have been looking through the jQuery documentation and I see how to update the the value of a textbox however how does one do a new tally every time a new checkbox is "checked". Also, what happens when a checkbox is "un-selected". Is there a way to store the value of each item in the HTML code of the checkbox?
I have a jsFiddle example I have been fooling with here ...
Add value
with price to the checkboxes and count it. Here is: http://jsfiddle.net/fQTUp/9/
这篇关于jQuery - 获取总计取决于选择哪个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!