2013-03-12 62 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