我正在尝试制作一个非常简单的音频播放器,我遇到了这个 Fiddle:http: //jsfiddle.net/yJfbX/2/ 这是我真正需要的,但问题是我真的可以 STYLE 吗?
这是代码:
JS: var audio = new Audio();
playlist = $('#playlist');
playlist.on('click', 'li', function() {
playlist.find('.current').removeClass('current');
$(this).addClass('current');
audio.src = $(this).data('src');
audio.play();
}).find('li:first').trigger('click');
audio.controls = true;
document.body.appendChild(audio);
HTML:
<ul id="playlist">
<li data-src="http://dp0169.free.fr/Musique/Air/Air%20-%20Talkie%20Walkie/02%20Cherry%20Blossom%20Girl.mp3">Cherry Blossom Girl (AIR)</li>
<li data-src="http://dp0169.free.fr/Musique/Air/Air%20-%20Talkie%20Walkie/04%20Universal%20Traveller.mp3">Universal Traveller (AIR)</li>
<li data-src="">Another Day (AIR(</li>
</ul>