我在我的网站上使用 jquery 1.3。今天我将其更新到最新的 1.9,并且我的切换/动画脚本停止工作。
代码如下所示:
<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);
});
});
这段代码有什么问题?当我将 jquery 1.3 包含到我的 html 中时,一切正常。
Try this
<a href="#" id="toggler" data-show="no">Show more</a>
and
$(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");
}
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)