Im using the slick.js library and have the following lines of code on my web page, which will allow me to randomise the order of the slides in the carousel.
JavaScript/jQuery:
$('.qa').on('init', function(event, slick, currentSlide, nextSlide) {
// Randomize the slides and then run slick slider
$.fn.randomize = function(selector) {
var $elems = selector ? $(this).find(selector) : $(this).children(),
$parents = $elems.parent();
$parents.each(function() {
$(this).children(selector).sort(function(){
return Math.round(Math.random()) - 0.5;
}).detach().appendTo(this);
});
return this;
};
$('.qa').find('.slick-track').randomize('.slick-slide');
});
As I'm not very familiar with JavaScript/jQuery, how would I be able to randomise the order of my slides (which it currently does) except for the very last one (which would be in its order)?