UPDATE: I switched .bind
to .on
because it's now the preferred way says jQuery.
As of jQuery 1.7, the
.on()
method is the preferred method for attaching event handlers to a document. jquery.com
EXAMPLE:
$('.button').on("click touchstart", function() {
});
Below is the ultimate version of the click
and touchstart
event because it still fires even with new DOM objects that are added after the DOM has been loaded. Incorporating this ultimate click event solution for any scenario.
$(document).on("click touchstart", ".button", function () {
});