2013-03-30 71 views
0

嗨!我只是jquery功能的新手,我能完成一定的div隐藏/显示功能,但我想在中心的方式,使在执行秀格。现在这些div有一个内容,但是当我点击秀它从左到右显示..有人可以做这些诡计为中心吗?jquery hide /显示功能

window.onload = function(){ 
    $('#show').click(function() 
    { 
     $('#nav').show('blind'); 
     $('#show').hide(); 
     $('#hide').show(); 
    }); 

    $('#hide').click(function() 
    { 
     $('#nav').hide('blind'); 
     $('#hide').hide(); 
     $('#show').show(); 
    }); 
} 
+0

请提供HTML和CSS代码 – egig

回答

1

使用.toggle()对于在相同time.u做既隐藏和显示不需要写显示和隐藏功能分别

http://api.jquery.com/toggle/

<!DOCTYPE html> 
<html> 
<head> 
<style> 
p { background:#dad; 
font-weight:bold; 
font-size:16px; } 
</style> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
</head> 
<body> 
<button>Toggle 'em</button> 
<p>Hiya</p> 
<p>Such interesting text, eh?</p> 
<script> 
$("button").click(function() { 
$("p").toggle("slow"); 
}); 
</script> 
</body> 
</html> 
+0

我知道了,谢谢,,但我想知道是否有可能获得例如在演示中心(从基准隐藏显示的那个状态),,而不是执行从在点击切换按钮从左到右? –

+0

如果你想从中心像介绍弹出看到这个链接http://jqueryui.com/toggle/ –