我有很多的这些功能在此刻:重构的jQuery/JavaScript代码
function show_foo() {
$('.modal').hide(); // hide all modals
$('#foo').show(); // show the foo modal
}
function show_bar() {
$('.modal').hide();
$('#bar').show();
}
麻烦的是,我对这些功能10,它看起来笨拙。有没有更优雅的方式来做这种事情?
非常感谢。
给该函数一个统一的名称并将该ID作为参数传递? – dbf 2013-04-22 08:41:09