jQuery (jQuery.fn) , , this jQuery, $('.carousel'), carousel. , this, .
, , , , . .each() . , , this DOM, jQuery, $(this).
, var $this = $(this) "", . , advanceSlide - , , $this, advanceSlide.
, $this, this , . ( , .) , $carousel, , .
advanceSlide , function() { }, .click() ( .on()).
, , JSFiddle:
$.fn.swapify = function () {
this.each(function () {
var $carousel = $(this);
function advanceSlide() {
$carousel.find('li:first-child').appendTo($carousel);
}
$carousel.find('li').on('click', advanceSlide);
});
}
$(document).ready(function () {
$('.swapify').swapify();
});