javascript or jquery : mouse events
VJS’s Question:
Need your help in understanding this code..Is this Javascript ( expression language ) or JQuery. I tried to understand but didn’t get it.
var interval = 0, changed = false;
...............
...............
var start = function () {
$(document).on('mousedown mousemove scroll touchstart touchmove keydown', change);
setInterval(check, 1000);
};
var change = function () {
changed = true;
};
var check = function () {
console.log("changed .....");
};
start();
Basically I want to do something ( business logic ) if user had performed some events on browser.Got this code on net and felt like something this is doing the same what i want.
This following part is jQuery specific, all other are pure JavaScript.
$(document).on('mousedown mousemove scroll touchstart touchmove keydown', change);
This is a event handler of jQuery which is calling a native javascript function change()
.
Notes:
-
To run the jQuery part you need to import jQuery Library from their site.
-
You can identify the jQuery selectors by user of
$
infront. ($
does not always means jQuery)