谁能帮我解决这个问题?
当我使用最新(或较新)版本的 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);
})
})
任何形式的帮助表示赞赏。
你必须使用bind http://api.jquery.com/bind/代替on http://api.jquery.com/on, as on
才被引入jQuery 1.7 http://blog.jquery.com/2011/11/03/jquery-1-7-released/.
$(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);
})
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)