【问题标题】:required input type number up and down arrow hold to increment functionality for a span and input text所需的输入类型编号向上和向下箭头按住以增加跨度和输入文本的功能
【发布时间】:2014-06-09 15:14:39
【问题描述】:
我们如何在手机中实现点击保持输入类型数字增加1,
<input type="text" id="number" value="1">
<span id="upSpan"> Up </span>
$('#upSpan').on('touchstart', function(){ var value = $('#number').val(); $('number').val(value + 1);})
这需要作为输入类型号。
【问题讨论】:
标签:
javascript
jquery
jquery-mobile
touch-event
【解决方案1】:
工作示例:http://jsfiddle.net/Gajotres/4fewN/
HTML:
<input type="text" id="number" value="1"/>
<span id="upSpan"> Up </span>
JavaScript:
$('#upSpan').on('vclick', function(){
var value = parseInt($('#number').val());
$('#number').val(value + 1);
});