我有下面的代码滑动隐藏的内容区域。它有效,但我怀疑它太笨拙,可能会触发太多请求或事件。有人可以提出一种更有效地结合这些功能的方法吗?凝聚/优化jQuery代码
$(".toggler").click(function (event){
event.stopPropagation();
$("#mobile-top").animate({'height':'toggle'}, 250);
});
$("#mobile-top").click(function(event){
event.stopPropagation();
});
$('.toggler').toggle(function() {
$(this).html('Close This Box <em class="fa fa-chevron-up"></em>');
}, function() {
$(this).html('Connect With Us! <em class="fa fa-chevron-down"></em>');
});
$('html').click(function(){
$("#mobile-top").slideUp();
$(".toggler").html('Connect With Us! <em class="fa fa-chevron-down"></em>');
});
工作代码要改进的建议通常属于上http://codereview.stackexchange.com。 – jfriend00 2014-09-29 23:10:49