Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试了这段代码,可见是函数的参数:
$('#something').show(isVisible);
但这不起作用,必须评估:
if (isVisible) $('#something').show(); else $('#something').hide();
$('#something').toggle(isVisible);
文档:
.toggle( showOrHide )
showOrHide 一个布尔值,指示是否显示或隐藏元素
var arr = ['show', 'hide']; $('#something')[arr[isVisible & 1]]();