[HTML] syntaxhighlighter_viewsource syntaxhighlighter_copycode
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html>
<head runat="server">
<meta name="viewport" content="width=device-width" />
<script type ="text/javascript" src="/Scripts/jquery-1.8.3.min.js" ></script>
<title>悬挂按钮</title>
<style>
body{
background-color: aliceblue;
}
#audio_btn {
background: aliceblue;
position:fixed;
right:1px;
}
</style>
</head>
<body>
<div id="audio_btn" <%--class="rotate"--%>>
<img id="imgBtn" style="width:50%;height:50%;" class="rotate" src="../../Content/MICON.png" />
<audio loop src="../../Content/MICON.png" id="media"></audio>
</div>
<script>
var x = document.getElementById("media");
//$(function(){
$("#imgBtn").click(
function () {
//alert("aaa");
$("#imgBtn").toggleClass("rotate");
if ($("#imgBtn").hasClass("rotate")) {//判断div是否包含指定类名,并指定音乐是否播放
x.play();
} else {
x.pause();
}
}
);
//})
</script>
</body>
</html>
|