简体   繁体   中英

required input type number up and down arrow hold to increment functionality for a span and input text

How can we achieve input type number on tap hold increase value by 1 in mobile,

<input type="text" id="number" value="1">
<span id="upSpan"> Up </span>


$('#upSpan').on('touchstart', function(){ var value = $('#number').val(); $('number').val(value + 1);})

This need to be worked as input type number.

Working example: 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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM