2010-05-11 40 views
1

之後,我的特林具有動畫效果後集中一個textarea:重點動畫

$("#textarea").live("click",function(){ 
     if ($(this).attr("class") != "textarea_clicked") { 
      $(this).val("");    
      $(this).animate({ 
       height: "+=30" 
      }, 150, function(){ 
       $(this).attr("class", "textarea_clicked"); 
       $(this).elastic(); 
       $(this).focus();     
      }); 

     } 
    }) 

但它不工作。

我該怎麼做?

感謝

+0

textarea是一個真正的textarea嗎?不是一些豐富的編輯器的包裝? – 2010-05-11 13:54:51

+0

請注意,'.live()'不再適用於jQuery 1.9。改用'.on()'。 – viclim 2013-04-03 09:22:21

回答

0

試試這個:

$("#textarea").live("click",function(){ 
     if ($(this).attr("class") != "textarea_clicked") { 
      $(this).val("");    
      $(this).animate({ 
       height: "+=30" 
      }, 150, function(){ 
       $(this).attr("class", "textarea_clicked"); 
       $(this).elastic(); 
      }); 

      $(this).focus(); 
     } 
    }) 
0

我知道這是一個老問題,但爲了完整起見,這裏是一個代碼,你想要做什麼:

$("#textarea").on("click",function(){ 
    if (!$(this).hasClass(textarea_clicked)) { 
     $(this).val("");    
     $(this).animate({ 
      height: "+=30" 
     }, 150, function(){ 
      $(this).addClass("textarea_clicked"); 
      $(this).elastic(); 
      $(this).focus();     
     }); 
    } 

});