Javascript 使用audioplayer.js,希望通过使用控件播放下一首曲目
我有一个手风琴和录音带。我想使控件成为下一个/上一个。找工作。现在单击Javascript 使用audioplayer.js,希望通过使用控件播放下一首曲目,javascript,jquery,audio,Javascript,Jquery,Audio,我有一个手风琴和录音带。我想使控件成为下一个/上一个。找工作。现在单击$(此)选项卡切换,但另一个未打开,下一个曲目未播放。;(按下下一个/上一个控制按钮时,想要打开下一个手风琴和播放曲目。 以下是我的手风琴JS代码: var next = jQuery('.my_music').find('.accordion-toggle'); next.click(function(){ jQuery(this).next().slideToggle('fast'); jQuery
$(此)
选项卡切换,但另一个未打开,下一个曲目未播放。;(按下下一个/上一个控制按钮时,想要打开下一个手风琴和播放曲目。
以下是我的手风琴JS代码:
var next = jQuery('.my_music').find('.accordion-toggle');
next.click(function(){
jQuery(this).next().slideToggle('fast');
jQuery(".accordion-content").not(jQuery(this).next()).slideUp('fast');
});
切换下一曲目:
jQuery('.next_music').click(function(){
// jQuery(next).next().slideToggle('fast');
// cl(this);
jQuery(".accordion-content").not(jQuery(this).next()).slideUp('fast');
});
-此处示例编辑(删除了我的第一个答案…测试了这个答案。工作!;)
我重新命名了你的
next
var,因为它让人困惑。你应该把你网站的链接而不是我的clonage…我把它粘贴到我的网站上,结果出了问题)手风琴打开和关闭随机选项卡)你在clonage上测试过吗?)我们到了!请参阅第一首歌曲上的警报单击。。。在第五首歌中,单击;)全部完成。有趣的是,我正在用这种问题学习jQuery。谢谢你!;)现在它是完美的;)正确的!第一:我会把他们归为另一类。像
$(".next_music").click(function(){
var actualAccordion = $(this).parent().parent().parent('.accordion-content');
console.log("next clicked");
// find the accordion below by getting it's parent's next element (".my_music_wrap").
belowAccordion = actualAccordion.parent().next().children('.accordion-toggle').first();
// Toggle it!
if(belowAccordion.length>0){ // If an accordion is found
actualAccordion.first().slideToggle('fast'); // Toggles actual accordion.
belowAccordion.click() //.slideToggle('fast');
belowAccordion.next().first().children().children().children().children(".audioplayer-playpause").click();
}else{
alert('No other song to play!'); //Will happen on the next button of the fifth song.
}
});
$(".prev_music").click(function(){
var actualAccordion = $(this).parent().parent().parent('.accordion-content');
console.log("prev clicked");
// find the accordion below by getting it's parent's next element (".my_music_wrap").
aboveAccordion = actualAccordion.parent().prev().children('.accordion-toggle').first();
// Toggle it!
if(aboveAccordion.length>0){ // If an accordion is found
actualAccordion.first().slideToggle('fast'); // Toggles actual accordion.
aboveAccordion.click() //.slideToggle('fast');
aboveAccordion.next().first().children().children().children().children(".audioplayer-playpause").click();
}else{
alert('No other song to play!'); //Will happen on the prev button of the first song.
}
});