2013-03-12 54 views
0

我想slideDown()一個隱藏的div但它只顯示()它沒有slideDown()效果。當我的時鐘按鈕內容2-3秒 後突然apears這裏是JSslideDown不工作或工作像.show

var hash = window.location.hash.substr(1); 
var href = $('#nav li a').each(function(){ 
    var href = $(this).attr('href'); 
    if(hash==href.substr(0,href.length-5)){ 
     var toLoad = hash+'.html #content'; 
     $('#content').load(toLoad) 
    }           
}); 

$('#nav li a').click(function(){ 

    var toLoad = $(this).attr('href')+' #content_id1'; 
    $('#content').fadeOut(1000,loadContent); 
    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
    function loadContent() { 
     $('#content').load(toLoad,'',showNewContent()) 
    } 
    function showNewContent() { 
     $('#content').slideDown('normal'); 


    } 
    return false;  
}); 

這裏是CSS

#content {width:934px;margin-top:238px;position:relative;height:500px;display:none;} 
#content #content_id1{width:934px; background-color:white; height:500px; position:relative;top:4px;margin-top:238px;margin-bottom:50px;padding:20px;} 

,這裏是HTML

  <ul id="nav"> 
       <li> 
        <a href="products/rania.php"><img src="img/products/1.jpg"/></a> 
       </li> 
       <li class="under"> 
       <a href="products/lutron.php"><img src="img/products/2.jpg"/></a> 
       </li> 

      </ul> 

      <div id="content"> </div> 
+0

[縮小的測試用例](http://css-tricks.com/reduced-test-cases/)會有幫助。 – Whymarrh 2013-03-12 11:46:40

+0

在$('#content')中從'showNewContent()'中移除缺省值。load(toLoad,'',showNewContent())' - 使用它們調用'showNewContent()'並指定返回值'undefined')作爲'.load()'''完成'處理程序' – Andreas 2013-03-12 11:48:29

+0

謝謝Andreas。這是有幫助的 – BahaS 2013-03-12 11:52:22

回答

0

閱讀jQuery's APIslideDown()normal沒有參數,持續時間應該是數值或slowfast

+0

如果['jQuery.fx.speeds'](http://code.jquery.com/jquery.js)中找不到值('normal'),['_default'](http: //jsapi.info/jquery/1.8.3/jQuery.speed)使用的值是'400' - 'slow:600'和'fast:200'的中間值# – Andreas 2013-03-12 12:11:50

+0

@Andreas感謝您指點:) – Morpheus 2013-03-12 13:06:30