Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  131] [ 6]  / answers: 1 / hits: 67084  / 11 Years ago, tue, september 3, 2013, 12:00:00

I know 'mousedown' is when user press the mouse, 'mouseup' is when user release the mouse. But I want to listen the event after user press the mouse and hold it until it release. Any ideas?


More From » jquery

 Answers
23

If you want the hold state then it will be the state when you are in mousedown event state for a while. This state exists when you press mousedown but not mouseup. Hence you need to take a variable which records the current state of the event.



JS



$('div').on('mousedown mouseup', function mouseState(e) {
if (e.type == mousedown) {
//code triggers on hold
console.log(hold);
}
});


Working Fiddle


[#75943] Sunday, September 1, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janjadonb

Total Points: 4
Total Questions: 114
Total Answers: 118

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
janjadonb questions
;