Uncaught TypeError: Object [object Object] has no method 'on'
You must use bind
instead of on
, as on
was only introduced in jQuery 1.7.
$(document).ready(function () { $(".theImage").bind("click", function(){ // In the event clicked, find image, fade slowly to .01 opacity $(this).find("img").fadeTo("slow", .01).end() // Then, of siblings, find all images and fade slowly to 100% opacity .siblings().find("img").fadeTo("slow", 1); })})
You could use delegate()
, for example:
$("table").delegate("td", "click", function() { $(this).toggleClass("chosen");});
This is equivalent to the following code written using on()
:
$("table").on("click", "td", function() { $(this).toggleClass("chosen");});