How can I check if scrolling or clicking has occurred by jquery? I can check each of these events separately (scroll / click on the page), but how can I check that if any of them happen, the user can go to the next step?
Asked
Active
Viewed 106 times
0
-
For click, see https://stackoverflow.com/questions/8054429/how-do-i-handle-a-click-anywhere-in-the-page-even-when-a-certain-element-stops, and scroll https://stackoverflow.com/questions/19375636/jquery-onscroll-not-firing-the-event-while-scrolling – dlane Nov 19 '20 at 19:54
-
thanks but you suppose if user use mouse then do it. – zharf pzh Nov 19 '20 at 20:01
-
Look up the mousewheel event in JS or jQuery. This site or your favorite search engine will find an example for you. Getting into this field will require research and trial and error, so this is a good skill to have. People are here to help lead you in the right direction and also provide you the tools to grow, not just solve problems. – dlane Nov 19 '20 at 20:03
1 Answers
0
Use the on('event(s)', 'selector', function() {})
You may use more than 1 events with .on()
$(document).on('click scroll mouseup', '#target', function(event) {
event.preventDefault();
// your script
});
or bind 1 event this way
$("#target").click(function(event) {
event.preventDefault();
// your script
});
You also may use other events, for example keyup, doubleclick, etc. etc. For a full list see https://api.jquery.com/category/events/

bron
- 1,457
- 1
- 9
- 18