dvl*_*den 28 jquery bind onclick
任何人都可以帮我解决这个问题吗?
当我使用jQuery的最新版本(或新版本)时,下面的小脚本工作正常.但是,当我使用旧版本的jQuery时,我的脚本说该on
函数不存在.
这是我的脚本,不适用于旧版本的jQuery:
$(document).ready(function () {
$(".theImage").on("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);
})
})
Run Code Online (Sandbox Code Playgroud)
任何形式的帮助表示赞赏.
Ael*_*ios 75
你必须使用bind
而不是on
像jQuery 1.7中on
引入的那样.
$(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);
})
})
Run Code Online (Sandbox Code Playgroud)