解決看評論下方CSS DIV定位和jQuery的效果基本show瘋狂
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#playlistToggle').click(function(event) {
event.preventDefault();
if($('#playlist').is(":hidden"))
{
$('#playlist').slideUp('medium');
}
else
{
$('#playlist').slideDown('medium');
}
});
});
</script>
<style type="text/css">
#playlist_wrapper
{
bottom: 30px;
height: 75px;
overflow: hidden;
position: fixed;
width: 100%;
background-color: yellow;
}
#playlist
{
background-color: #FF6633;
border: 1px solid #666666;
height: 75px;
width: 920px;
position: relative;
bottom: 0;
margin: 0 auto;
visibility: hidden;
}
</style>
</head>
<a href="#" id="playlistToggle">Toggle Playlist</a>
<div id="playlist_wrapper">
<div id="playlist"></div>
</div>
這個腳本應該當你點擊該按鈕向上滑動播放列表格。但是,當你擊中它時什麼都不會發生。如果你改變:
如果($( '#播放列表')是( 「:隱藏」))
要:
如果($( '#播放列表' ).is(「:visible」))
並將css #playlist visibility屬性從「hidden」更改爲「display」,然後div滑動到頂部,然後滑動到底部,與我想要的完全相反。我在這裏做錯了什麼?
編輯:澄清:我需要從一開始就隱藏播放列表div,然後當我點擊切換按鈕時向上滑動。
如果我恢復'if'語句中的函數,它仍然沒有做任何事情? – 2011-02-03 23:11:18
您不能使用slideDown(顯示功能)使某些東西從屏幕底部向上滑動,這就是您的問題。你必須重新思考你在做什麼。 – 2011-02-03 23:28:39