2014-02-23 127 views
0

我對html,jquery和css非常陌生。我試圖創建一個導航欄,當我點擊該導航欄時,它將打開一個jquery slidedown,但它不是按照預期的方式工作。下面是我對這個目的編寫的代碼的一小部分slidedown不按預期的方式工作

 html: 
      <ul class="dropdown"> 
     <li id="cl1"><a class="ab" href="#">About </a></li > 
      </ul> 
     css: 
      <div class="target" style="z-  
        index:3;width:1000px;height:1000px;display:none;background-  
        color:white;opacity:0.8;position:fixed;top:0px;left:0px;">         
      <img src="horse.jpg" alt="horse" /> 
      </div> 
     jquery: 
       $(document).ready(function() { 

       $(".ab").click(function(){ 
        $(".target").slideDown('slow', function()); 
       }); 
       }); 


      there are more sub menus to the above html 

回答

0

你有語法錯誤在這行

$(".target").slideDown('slow', function()); 

應該

$(".target").slideDown('slow', function(){}); 

這裏是一個全版本

$(document).ready(function() { 
     $(".ab").click(function(event){ 
      $(".target").slideDown('slow', function(){ 
      // after animation code here 
      });  
      return false; //this for preventing the default event of you can use event.preventDefault(); 
     }); 
    }); 
+0

你忘了添加在功能上的報價,以及加引號{}函數...你寫同樣的事情兩次:) – gurudeb

+0

笑,對不起都沒睡好 – Reda

0
$(".ab").click(function(){ 
    $(".target").slideDown('slow', function(){}); 
}); 

你忘了