I'm trying to make a shuffle button for my HTML 5 player. My player is set up like this to go the next track:
$('.nextbutton').on("click", function(){
var next = $('li.playing').next();
if (!next.length) next = $('#stuff ul li').first();
next.addClass('playing').siblings().removeClass('playing');
var title = $('a#tunes img', next).attr("title");
$("a.songtitle span").text(title);
var artist = $('a#tunes img', next).attr("artist");
$("a.songartist span").text(artist);
audio.load($('a#tunes', next).attr('data-src'));
audio.play();
});
This code works to go to the next song but how can I change this to make it so it selects a random <li>
element instead of the .next();
<li>
? Thanks for your time and consideration. Hope you can help me!