Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript variable shortcuts 
Javascript :: javascript for border color 
Javascript :: get next month js 
Javascript :: js get element by class 
Javascript :: checking if var is not defined js 
Javascript :: how to zip two arrays in javascript 
Javascript :: javascript getmonth 
Javascript :: increase font size in jsx 
Javascript :: settimestamp discord.js 
Javascript :: download image from url javascript 
Javascript :: find year javascript 
Javascript :: how to get session javascript ws3schools 
Javascript :: empty the value of an input in jquery 
Javascript :: $.dialog after create focus 
Javascript :: mongodb unshift array 
Javascript :: drupal 8 node has field 
Javascript :: javascript context arc set color 
Javascript :: how to filter an array of objects in javascript 
Javascript :: jquery get label from select 
Javascript :: remove extra spaces javascript 
Javascript :: how to change the staticness of a object in matter.js 
Javascript :: node:internal/crypto/hash:67 this[kHandle] = new _Hash(algorithm, xofLen); 
Javascript :: javascript test if element has focus 
Javascript :: how to get browser url in javascript 
Javascript :: replace non alphanumeric javascript 
Javascript :: convert buffer to base64 javascript 
Javascript :: express serve static files 
Javascript :: javascript autoplay audio 
Javascript :: Make Array Consecutive javascript 
Javascript :: fakepath file show in html page in js 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =