Javascript切换单击关闭
我正在为一个页面添加几个扩展div,但是在另一个div扩展时,让这些div自动折叠遇到了麻烦。以下是我正在使用的脚本:Javascript切换单击关闭,javascript,hide,expand,Javascript,Hide,Expand,我正在为一个页面添加几个扩展div,但是在另一个div扩展时,让这些div自动折叠遇到了麻烦。以下是我正在使用的脚本: $(document).ready(function() { $('.nav-toggle').click(function(){ var collapse_content_selector = $(this).attr('href'); var toggle_switch = $(this);
$(document).ready(function() {
$('.nav-toggle').click(function(){
var collapse_content_selector = $(this).attr('href');
var toggle_switch = $(this);
$(collapse_content_selector).toggle(function(){
if($(this).css('display')=='none'){
}
});
});
});
试试这个:
$(document).ready(function() {
$('.nav-toggle').click(function() {
var selected = $($(this).attr('href'));
$(".tab").not(selected).hide();
selected.toggle();
});
});
用可扩展div使用的类替换.tab
。到.toggle()
的参数不是函数。