javascript $(document).on('click') 在 html 中不起作用

javascript $(document).on('click') doesn't work in html

下面是我的 .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>

您需要先添加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>