Javascript 音频自动播放
所以我一分钟前还在这里,想找到一种方法来做这件事,它想出了这个Javascript 音频自动播放,javascript,jquery,html,Javascript,Jquery,Html,所以我一分钟前还在这里,想找到一种方法来做这件事,它想出了这个 $(document).ready(function() { var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'mixtaperainbow.mp3'); audioElement.setAttribute('autoplay', 'autoplay'); //audioEleme
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'mixtaperainbow.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
//audioElement.load()
$.get();
audioElement.addEventListener("load", function() {
audioElement.Play();
}, true);
$('.Play').click(function() {
audioElement.Play();
});
$('.Stop').click(function() {
audioElement.Stop();
});
});
但我不能不自动播放声音。。。有人请帮忙你把属性设置为自动播放吗?可能注释掉这行audioElement.setAttribute('autoplay','autoplay')@地板我已经试过了,但是它根本不起作用。当你注释掉那一行时,你在控制台中有错误吗?@floor控制台中没有显示任何东西aaah,soo。。。我累了,只需删除:audioElement.setAttribute('autoplay','autoplay');:)