我正在写一个Javascript代码,我需要显示和隐藏网页的某些部分。我结束了这样的功能:使用单行功能或重复代码
function hideBreakPanel() {
$('section#break-panel').addClass('hide');
}
function hideTimerPanel() {
$('section#timer-panel').addClass('hide');
}
function showBreakPanel() {
resetInputValues();
$('section#break-panel').removeClass('hide');
}
function showTimerPanel() {
resetInputValues();
$('section#timer-panel').removeClass('hide');
}
我的问题是与代码质量和重构。什么时候最好有这些简单的函数或直接调用Javascript/jQuery函数?我想最后一种方法有更好的性能,但在这种情况下,性能不是问题,因为它是一个非常简单的网站。
感谢您的回答。问题解决了;) –
很高兴帮助你 - 对不起,我一直在更新答案,因为我想到了它 –