<!DOCTYPE HTML>
<html>
<head>
<script type=”text/javascript”>
function autoPlay(type){
var myAuto = document.getElementById(‘myaudio_’+type);
myAuto.play();
}
$(function () {
//存在alert-danger样式时自动播放音乐
if($(“.alert-danger”).length){
autoPlay(“alert-danger”);
}
});
</script>
</head>
<body>
<audio id=”myaudio_alert-danger” src=”http://www.ssqhm.com/static/alert-danger.mp3″ controls=”controls” loop=”false” hidden=”true”></audio>
<div class=”alert-danger”>test alert-danger class div </div>
<input type=”button” onclick=”autoPlay()” value=”点击播放”/>
</body>
</html>
本文固定链接: http://www.ssqhm.com/1943.html
暂无评论