One key to play and stop music


<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习 </title>
    <style>
              *{
  margin:0;
  padding:0;
  list-style:none;}
  div{
  height:50px;
  width:56px;
  background:url(images2/musicBtn.gif) no-repeat left top;}
  .current{
  background:url(images2/musicBtn.gif) no-repeat left bottom;}
    </style>
     <script src="js/jquery-3.3.1.js"></script>
</head>
<body>
<audio autoplay id="muc1">
    <source src="lib/home.ogg"/>
    </audio>
<div class="plmus"></div>
    <script>
$(document).ready(function(e) {
           var picsTatus=true;
  var muc1=document.getElementById("muc1");
  $(".plmus").click(function(){   if(picsTatus){   console.log("play to pause");   $(".plmus").addClass("current");  muc1.pause(); // muc1.pause();   picsTatus=false;   }else{ $(".plmus").removeClass("current");  muc1.play();   picsTatus=true;   }   });         });     </script> </body> </html>
 















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324505307&siteId=291194637