首页 > 其他分享 >mui开发记录(七)动态改变audio标签的播放源

mui开发记录(七)动态改变audio标签的播放源

时间:2023-02-06 17:02:36浏览次数:38  
标签:function play 标签 innerHTML getElementById str audio mui


效果图

mui开发记录(七)动态改变audio标签的播放源_mui框架

代码如下

<div class="tan">
<div id="audio"></div>
<div class="play_b">
<div class="y1" >
<button type="button" onclick="play(1)" id="y1">1</button>
</div>
<div class="y2" >
<button type="button" onclick="play(2)" id="y2">2</button>
</div>
<div class="y3" >
<button type="button" onclick="play(3)" id="y3">3</button>
</div>
<div class="y4" >
<button type="button" onclick="play(4)" id="y4">4</button>
</div>
<div class="y5" >
<button type="button" onclick="play(5)" id="y5">5</button>
</div>
<div class="y6" >
<button type="button" onclick="play(6)" id="y6">6</button>
</div>
<div class="y7" >
<button type="button" onclick="play(7)" id="y7">7</button>
</div>
</div>
</div>
<script>
function play(str){
document.getElementById("audio").innerHTML='<audio autoplay="autoplay"><source type="audio/mp3" src="fonts/'+str+'.wav"></source></audio>';

}
</script>

 

标签:function,play,标签,innerHTML,getElementById,str,audio,mui
From: https://blog.51cto.com/u_15955908/6039830

相关文章