2011-11-29 52 views
4

我正在使用jQuery的插件flip。我想翻轉一張卡片(div),當它完成翻轉後,立即恢復翻轉它。這就是我試過的我需要翻轉懸停的div

$("#flipbox").bind("hover",function(){ 
    $(this).flip({ 
     direction:'tb', 
     onEnd: function() { 
      $(this).revertFlip(); 
      console.log('when the animation has already ended'); 

     } 
    }) 
} 
+2

所以有什麼問題了嗎? –

+0

你可以嘗試在jsfiddle上重新創建嗎? –

+0

它翻轉但不翻轉,還是不翻轉? – Qqwy

回答

0

試圖作弊。 製作2個不同的課程,

然後使用mouseenter事件更改課程並將其更改回mouseleave事件。

至少,這就是那種東西我時,即時通訊接近我的最後期限:P

+0

我已經試過了mouseenter和mouseleave。這是行不通的。 –

1

試試這個:http://jsfiddle.net/netwire88/NAbZT/16/

$(document).on("click", ".flipbox-forward", function(e) { 
    e.preventDefault(); 
    var $this = $(this); 
    $this.flip({ 
     direction: $this.data("direction"), 
     color: $this.data("color"), 
     content: $this.data("title"), 
     onBefore: function() { 
      $this.removeClass('flipbox-forward'); 
      $this.addClass('flipbox-revert'); 
     } 
    }) 
}); 

$(document).on("click", ".flipbox-revert", function(e) { 
    e.preventDefault(); 
    var $this = $(this); 
    $this.revertFlip(); 
    $this.removeClass('flipbox-revert'); 
    $this.addClass('flipbox-forward'); 
});​