哪个JavaScript函数可以同时播放多个音频?[已关闭]

pb3skfrl  于 12个月前  发布在  Java
关注(0)|答案(1)|浏览(75)

已关闭,此问题需要更focused。它目前不接受回答。
**想改善这个问题吗?**更新问题,使其只关注editing this post的一个问题。

去年就关门了。
Improve this question
我想让Moodly.site我可以添加一个音频,并可以让用户点击播放,但如何使1+音频播放。我不知道,我可以使它与香草JS或我需要与任何框架的工作。
在HTML中是否有任何标签可以让我这样做,或者它只是JS的一部分?

kgsdhlau

kgsdhlau1#

var a1 = document.getElementById("a1");
var a2 = document.getElementById("a2");

var b1 = document.getElementById("b1");
var b2 = document.getElementById("b2");

b1.addEventListener("click", function () {
        a1.play();
        
 });
 b2.addEventListener("click", function () {
        a2.play();
 });
<audio id="a1" src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3">
            Your browser does not support the
            <code>audio</code> element.
    </audio>
<audio id="a2" src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3">
            Your browser does not support the
            <code>audio</code> element.
    </audio>
    <button id="b1">1</button>
    <button id="b2">2</button>

确保更改音频文件

相关问题