jQuery更新后Toggle停止工作 [英] Toggle stopped working after jquery update
本文介绍了jQuery更新后Toggle停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的网站上使用的是jquery 1.3.今天,我将其更新为最新的1.9,并且切换/动画脚本停止工作.
I was using jquery 1.3 on my website. Today I updated it to newest 1.9 and my toggle/animate script stopped to work.
代码如下:
<a href="javascript: void(0);" id="toggler">Show more</a>
<div id="tcontent"> … </div>
$(document).ready(function() {
$('#toggler').toggle(
function() {
$('#tcontent').animate({height: "70"}, 800);
},
function() {
$('#tcontent').animate({height: "6"}, 800);
});
});
此代码有什么问题?当我在我的html中添加jquery 1.3时,一切正常.
What is wrong with this code? When I include back jquery 1.3 to my html everything works fine.
推荐答案
尝试一下
<a href="#" id="toggler" data-show="no">Show more</a>
和
$(function() {
$('#toggler').on("click",function(e) {
if ($(this).data("show")=="no") {
$('#tcontent').animate({height: "70"}, 800);
$(this).data("show","yes");
}
else {
$('#tcontent').animate({height: "6"}, 800);
$(this).data("show","no");
}
});
});
这篇关于jQuery更新后Toggle停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文