Time for action – adding touch event handlers
Extending the jQuery library is actually pretty easy. First we wrap our extensions in an immediately invoked function expression and pass the jQuery object into it. This is a best practice to make sure the dollar sign is really mapped to jQuery and not being used by something else. Then we define our extension methods by adding them to jQuery's internal $.fn
object:
(function($) { $.fn.touchstart = function(handler) { this.each(function(i, e) { e.addEventListener("touchstart", handler); }); return this; }; $.fn.touchmove = function(handler) { this.each(function(i, e) { e.addEventListener("touchmove", handler); }); return this; }; $.fn.touchend = function(handler) { this.each(function(i, e) { e.addEventListener("touchend", handler); }); return this; }; $.isTouchSupported = ("ontouchstart" in document.documentElement...