if button is keeping pressed execute increment javascript
var timeout;
var speed = 500;
// Increment button
$('#plus-btn').on('mousedown mouseup mouseleave', e => {
if (e.type == "mousedown") {
increment(speed);
} else {
stop()
}
});
// Increment function
function increment(speed) {
$('#qty-input').val(parseInt($('#qty-input').val()) + 1);
timeout = setTimeout(() => {
increment(speed * 0.8);
}, speed);
}
function stop() {
clearTimeout(timeout);
}
Also in JavaScript:
- c# razor for loop javascript
- react prevent back
- angular 7 folder structure best practices
- how to remove name in react navigation header
- nested if javascript
- data submit notification in javascript
- dom javascript cheat sheet
- google script get date without time
- events in javascript
- js remove the last character of a string
- get index of element in array js
- delete first character javascript
- Regular expression: Match everything after a particular word
- set dropdown in jquery
- how to copy text from input through button click js
- headroom js react
- how to limit characters in number input js
- javascript get all characters before a certain one
- javascript sendredirect
- how to get tomorrow date in javascript
- items in center in native
- route in component react
- cypress click
- Javascript check for hash in URL