是否可以输入数字时左边减号按钮右边加号按钮?或者也可能 --++ 以更大的步骤改变值。
我知道我不是第一个问这个问题的人,但是: This解决方案在第一回合中无法正确显示,并且来自 Github 的 jQuery-Mobile-Stepper-Widget(无法发布另一个链接,因为我是新人)不适用于当前版本的 jQuery Mobile。
结果应类似于此问题中的屏幕截图:Has anyone implemented jQuery Mobile Add (+/-) Button Number Incrementers? jQuery Mobile 中分别水平分组的按钮
使用当前版本的 jQuery mobile 有什么想法或新片段吗?
最佳答案
这里是一个提示,其余的纯粹是 CSS 工作和额外的 JS 代码来控制值,例如最大值、最小值...等
HTML
<div data-role="controlgroup" data-type="horizontal" data-mini="true">
<button id="plus" data-inline="true">+</button>
<input type="text" id="number" value="0" disabled="disabled" />
<button id="minus" data-inline="true">-</button>
</div>
代码
$('#plus').unbind('click').bind('click', function () {
var value = $('#number').val();
value++;
$('#number').val(value);
});
$('#minus').unbind('click').bind('click', function () {
var value = $('#number').val();
value--;
$('#number').val(value);
});
关于jquery-mobile - jQuery 移动 : number input and plus/minus buttons inline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15588358/