我的代码按我希望的方式工作,但我正在寻找任何关于如何 trim 或修改它以提高效率的评论:
$('.toggle-comments').hide(); // this hides the results div when the page loads.
$(".comments-toggle-click").click(function () {
$(".toggle-comments").slideToggle("slow");
$(".comments-toggle-click").remove();
});
最佳答案
与其在页面加载时调用 $('.toggle-comments').hide();
为什么不使用 display:none;
呈现评论?
关于javascript - jQuery toggle() 函数。我想要一些批评或建议以更好地实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8965532/