HTML 5 プレーヤーのシャッフル ボタンを作成しようとしています。私のプレーヤーは、次のトラックに移動するために次のように設定されています。
$('.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();
});
このコードは次の曲に移動するように機能しますが、これを変更して ?<li>
の代わりにランダムな要素を選択するにはどうすればよい.next();
<li>
ですか? お時間をいただきありがとうございます。あなたが私を助けてくれることを願っています!