2015-09-09 83 views
0

我有一個指定類的按鈕。點擊按鈕,驗證一些東西,並給予用戶一些迴應。前置,淡入和淡出結合

當第一次點擊按鈕時,它工作正常。每下一次點擊都不太好。

$(".hold").prepend($('<h3>Please insert name and comment</h3>').fadeIn('fast', function() { 
      $(".hold").fadeOut('slow'); 
    })); 

有些幫助嗎?

回答

0

爲什麼不嘗試這樣的:

<script> 
    $(function(){ 
     $(".hold").on("click",function(){ 
     $(this).prepend("<h3 class='added' style='display:none;'>Please insert name and comment</h3>"); 
     $(".added:last-of-type").fadeIn("fast"); 
     $(this).fadeOut("slow"); 
     }); 
    }); 
    </script> 
+0

以div的形式存在。在該div prepends內容。內容取決於用戶輸入。 – LoverBugs

+0

對不起,我不瞭解你的評論。 – Mark

+0

有這樣的: (「.save全新註釋」)點擊(函數(E){// 一些用戶驗證 //然後我來處理從我的帖子用戶輸入(代碼) 現在希望其清晰? – LoverBugs

0
$(".hold").attr("style","display:block"); 
     $(".hold").prepend($('<h3>Please insert name and comment</h3>').fadeIn("slow")); 
     setTimeout(function(){ 
      $(".hold").fadeOut("slow"); 
      $(".hold").html(''); 
     }, 1500); 

其實我需要setTimeout函數。