下面是我的.html代码文件,它似乎根本没有点击点击功能......我错过了什么?
我是新手,对此有任何帮助都会很棒!!
<html>
<body>
<h1> hello </h1>
<audio id="audio">
<source src="http://dl.dropbox.com/u/1538714/article_resources/song.ogg" type="audio/aac">
</audio>
<script type="text/javascript">
function dosomething(){
$('body').append('document click<br />');
document.getElementById('audio').play();};
$(document).on('click', function(){dosomething()});
</script>
</body>
</html>
答案 0 :(得分:1)
您需要先添加jQuery库
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<html>
<body>
<h1> hello </h1>
<audio id="audio">
<source src="https://dl.dropboxusercontent.com/u/40410302/rainbowride.aac" type="audio/aac">
</audio>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
function dosomething(){
$('body').append('document click<br />');
document.getElementById('audio').play();};
$(document).on('click', function(){dosomething()});
</script>
</body>
</html>
&#13;