jQuery实现简单音乐播放并计数
<!DOCTYPE html><html><head><title>简单音乐播放器</title><meta charset=\"utf-8\"><script type=\"text/javascript\" src=\"jquery-3.3.1.min.js\"></script></head><body><audio src=\"music/Devotion - My Prayer.mp3\" loop=\"loop\" autoplay></audio><audio src=\"music/宋立伟 - 陷阱.mp3\"></audio><audio src=\"music/涂军豪 - 追梦赤子心.mp3\"></audio><table border=\"1\" style=\"background: pink\"><tr style=\"background: #FFC125\"><td colspan=\"4\">简单音乐播放器</td></tr><tr><td>编号</td><td>歌曲名称</td><td>在线播放</td><td>点播计数</td></tr><tr><td>1</td><td>My Prayer</td><td><span id=\"mus1\">播放</span><img src=\"images/laba.png\"></td><td><span id=\"num1\">689</span></td></tr><tr><td>2</td><td>陷阱</td><td><span id=\"mus2\">播放</span><img src=\"images/laba.png\" onClick=\"play2()\"></td><td id=\"num2\">666</td></tr><tr><td>3</td><td>追梦赤子心</td><td><span id=\"mus3\">播放</span><img src=\"images/laba.png\" onClick=\"play3()\"></td><td id=\"num3\">666</td></tr></table></body><script type=\"text/javascript\">var ado = document.getElementsByTagName(\"audio\");$(function(){var count = $(\"#num1\").text();$(\"#mus1\").click(function(){count++;$(\"#num1\").text(count);})$(\"#mus1\").click(function(){if(ado[1].paused&&ado[2].paused){if (ado[0].paused) {ado[0].play();}else{ado[0].pause();}}else{alert(\"请先关掉当前音乐\")}});$(\'#mus1\').mouseover(function(){$(\"#mus1\").css(\"cursor\",\"pointer\");})});////////////////////////$(function(){var count=$(\"#num2\").text();$(\"#mus2\").click(function(){count++;$(\"#num2\").text(count);})$(\"#mus2\").click(function(){if(ado[0].paused&&ado[2].paused){if (ado[1].paused) {ado[1].play();}else{ado[1].pause();}}else{alert(\"请先关掉当前音乐\")}});$(\'#mus2\').mouseover(function(){$(\"#mus2\").css(\"cursor\",\"pointer\");})});//////////////////////////////$(function(){var count=$(\"#num3\").text();$(\"#mus3\").click(function(){count++;$(\"#num3\").text(count);})$(\"#mus3\").click(function(){if(ado[0].paused&&ado[1].paused){if (ado[2].paused) {ado[2].play();}else{ado[2].pause();}}else{alert(\"请先关掉当前音乐\")}});$(\'#mus3\').mouseover(function(){$(\"#mus3\").css(\"cursor\",\"pointer\");})});</script>