我的代码正在运行,但要求我点击两次以激活我的链接(一次用于点击事件,一次用于切换事件.)我该怎么做才能使我只需点击一次以便切换将自动发生?
//Show or Hide Comments
$('#showHideComments').live('click', function() {
$('#showHideComments').toggle(function() {
$(".commentsSwitch").animate({"marginLeft": "+=53px"}, 500);
$("#comments").fadeIn(300);
$("#addComment").fadeIn(300);
},function(){
$(".commentsSwitch").animate({"marginLeft": "-=53px"}, 500);
$("#comments").fadeOut(300);
$("#addComment").fadeOut(300);
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢!
jquery ×1