JarJarSqeeks
JarJarSqeeks

Reputation: 1

im trying to make a music player but my buttons are not working

when I click on the button on the browser it doesn't do anything I'm trying to make the play button work when I click on it its just not doing anything when I click on it I tried looking at the java script and it looks fine maybe its just a small thing that I cant find

var main = function() {
  var volume;
  //The PLAY button
  $('#play').(function() {
    $('#message').text("Playing track");
    $('#player').trigger("play");
  });
}

$(document).ready(main);
<!DOCTYPE HTML>
<html>

<head>
  <title>Music Player</title>
  <style>
    body {
      background: url(images/background.jpg);
      background-size: cover;
    }
    
    #cp {
      margin: 100px;
      text-align: center;
    }
    
    button {
      background-color: teal;
      padding: 10px;
      font-size: 20px;
      border: none;
      width: 100px;
    }
    
    #message {
      font-weight: bold;
      color: teal;
    }
  </style>
  <script src="code.jquery.com/jquery.min.js"></script>
  <script src="app.js"></script>
</head>

<body>
  <!-- Control Panel will go here -->
  <div id="cp">
    <button id="play">Play</button>

    <p id="message">Waiting</p>

  </div>
  <!-- Audio player will go here -->
  <audio id="player">
      <source src="music/song1.mp3" type="audio/mpeg">
    </audio>
</body>

</html>

Upvotes: 0

Views: 103

Answers (1)

MTP
MTP

Reputation: 171

You forgot to add event which you wanna listen to:

$('#play').(function()

In jQuery it should be:

$('#play').on("click", function(){

Upvotes: 1

Related Questions