function svgClippedSlider(element) { this.element = element; this.slidesGallery = this.element.find('.gallery').children('li'); this.slidesCaption = this.element.find('.caption').children('li'); this.slidesNumber = this.slidesGallery.length; this.selectedSlide = this.slidesGallery.filter('.selected').index(); // .... this.bindEvents(); } svgClippedSlider.prototype.bindEvents = function() { var self = this; //detect click on one of the slides this.slidesGallery.on('click', function(event){ if( !$(this).hasClass('selected') ) { //determine new slide index and show it var newSlideIndex = ( $(this).hasClass('left') ) ? self.showPrevSlide(self.selectedSlide - 1) : self.showNextSlide(self.selectedSlide + 1); } }); }