【发布时间】:2013-10-14 17:02:50
【问题描述】:
HTML:
<a id="the_link" class="folded" href="#">Click me</a>
<div id="content">This is some content to be toggled.</div>
分别显示或隐藏内容的两个函数:
function shower() {
$("body").on("click", "#the_link.folded", function(event) {
$("#content").show();
$("#the_link").html("Hde info").removeClass("folded").addClass("unfolded");
});
}
function hider() {
$("body").on("click", "#the_link.unfolded", function(event) {
$("#content").hide();
$("#the_link").html("See more info").removeClass("unfolded").addClass("folded");
});
}
If I use jQuery,代码有效:
$(document).ready(function() {
shower();
hider();
})
If I use Zepto,代码不起作用:
Zepto(function($){
shower();
hider();
})
为什么?
【问题讨论】: