本文在于巩固基础
新特性:音频的使用
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>播放音乐</title> <link rel="stylesheet" type="text/css" href="Css/myCss.css"/> <script src="Script/jquery-2.1.1.min.js"></script> </head> <body> <div> <h1>音乐播放</h1> <div> <button id="btn" onclick="clickMe()">播放/暂停</button> <audio id="audio" src="Source/Happiness.mp3" controls="controls"></audio> </div> </div> <script type="text/javascript" src="Script/myScript.js"></script> </body> </html>
/** * Created by Administrator on 2015/3/5 0005. */ function clickMe() { //$("#btn").css("background","red"); //$("#audio").css("background","red"); if($("#audio").get(0).paused) { $("#audio").get(0).play(); } else { $("#audio").get(0).pause(); } }
时间: 2024-10-10 16:51:34