Last Updated: February 25, 2016
·
787
· mlb

Use click & touch events the easy way

If you want to use touch events when available, use this tiny script :

var clickEvent = "createTouch" in document ? "touchend" : "click"

// and then
$(myElement).on(clickEvent, ...)
myElement.addEventListener(clickEvent, ...) 
myElement.listen(clickEvent, ...)