2013-07-11 4 views
1

Помогите мне кто-то с этим, я хочу, чтобы это сделать, когда нажмите исчезать и когда он снова через 3 секунды выгорает.Fade в и, JQuery

<script type="text/javascript"> 
$(".controls_next2").click(linkBind); 
function linkBind(){ 
    var $this = $(this); 
     $this.addClass('disabled'); 
     $this.unbind('click'); 
     setTimeout(function() { 
      $this.removeClass('disabled'); 
      $this.bind('click', linkBind); 
     }, 3000); 
} 

$(document).on('click', '.disabled', function (e) { 
    e.preventDefault(); 
}); 
</script> 

ответ

2

Вы можете использовать fadeOut и fadeIn функции JQuery в. Вы можете предоставить обратный вызов функции fadeOut, затем использовать setTimeout, чтобы подождать 3 секунды, а затем позвонить fadeIn.

function linkBind() { 
    var $this = $(this); 
    $this.addClass('disabled'); 
    $this.off('click'); 

    $this.fadeOut(function() { 
     setTimeout(function() { 
      $this.removeClass('disabled'); 
      $this.on('click', linkBind); 
      $this.fadeIn(); 
     }, 3000) 
    }); 
} 

Working Demo