2012-04-24 69 views

回答

1

我通過創建nextOrFirst和prevOrLast函數並觸發箭頭上的點擊來解決此問題。代碼見這裏:

// Fake click for video arrows // 

// Adds function nextOrFirst() // 
jQuery.fn.nextOrFirst = function(selector){ 
var next = this.next(selector); 
return (next.length) ? next : this.prevAll(selector).last(); 
} 

// Adds function prevOrLast() // 
jQuery.fn.prevOrLast = function(selector){ 
var prev = this.prev(selector); 
return (prev.length) ? prev : this.nextAll(selector).last(); 
} 

$(".icon-video-left-arrow").click(function() { 
$(".fader.active").prevOrLast().trigger("click"); 
}); 

$(".icon-video-right-arrow").click(function() { 
$(".fader.active").nextOrFirst().trigger("click"); 
});