2013-05-21 47 views
-1

下面的jQuery什麼都不做。 我錯過了逗號或什麼?以下jQuery有什麼問題

<script> 
$(".link<? echo $counter; ?>").click(function() { 
    $('.sub').toggle(function() { 
     $(".sub<? echo $counter; ?>").animate({ 
      height: ($(this).parent().height() * <? echo(count($$vari)); ?>) + 20 
     }, 1000); 
    }, function() { 
     $(".sub<? echo $counter; ?>").animate({ 
      height: 0 
     }, 1000); 
    }); 
});  
</script> 

控制檯不特羅任何錯誤的,當我更改代碼以

<script> 
$(".link<? echo $counter; ?>").click(function() { 
$(".sub<? echo $counter; ?>").animate({ 
height: ($(this).parent().height() * <? echo (count($$vari)); ?>) + 20 
}, 1000); 
}); 
</script> 

該腳本(除了撥動ofcource)

+0

什麼是控制檯錯誤和$$ vari的含義是什麼? –

回答

0

使用的toggle()功能的方式已在jQuery 1.9中刪除,現在只顯示和隱藏元素。 PHP輸出不可能讓我們知道,但是你通常不應該使用短標籤?

另請注意,您在點擊內部綁定點擊,並且每次點擊.link*元素時,都會將新事件處理程序綁定到.sub元素。

0

在您點擊鏈接之前,請在您的瀏覽器上使用開發人員工具,並確保監聽器實際上已添加到控件上。另外,你什麼意思是「什麼都不做」?你的期望是什麼?