Sound Generation on Clicking the Button using JavaScript Last Updated : 03 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The sound generation after clicking the button, receiving notifications, or at the time of page load can be done by using JavaScript. Note:URL provided in the playSound function can be changed to give the custom sound url. Style property is not the part of implementation. It is used to provide a nice interface for viewers.Example: This example generates the sound after clicking the button. html <!DOCTYPE html> <html> <head> <title> Sound generation after clicking the button </title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src='https://code.jquery.com/jquery-2.2.0.min.js'> </script> <script src='https://cdn.rawgit.com/admsev/jquery-play-sound/master/jquery.playSound.js'> </script> </head> <body style="text-align:center;"> <div class="container-fluid" style="margin:35px;"> <p style="font-size:30px;"> <strong> Click on the button to generate sound </strong> </p> <br><br> <button class="btn btn-primary" onclick='$.playSound( "https://media.geeksforgeeks.org/wp-content/uploads/20241003145702/WCSC5KW-message-notification.mp3")'> Click Me! </button> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Simulate a Click in JavaScript? M md1844 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads How to count the number of times a button is clicked using JavaScript ? At times, it becomes necessary to monitor the number of times a user clicks a button. In this article, we are going to learn how to count the number of times a button is clicked using JavaScript Below are the approaches to count the number of times a button is clicked using JavaScript Table of Conte 3 min read How to check a button is clicked or not in JavaScript ? Checking if a button is clicked in JavaScript involves detecting user interactions with the button element. This is typically achieved by adding an event listener, such as onclick or addEventListener(click), which triggers a specific function or action when the button is clicked.There are two method 2 min read How to trigger HTML button after hitting enter button in textbox using JavaScript ? In this article, we are given an HTML document containing a text area and the task is to trigger the button when the user hit Enter button. We can do it by using the "keyup", "keydown", or "keypress" event listener on the textbox depending on the need. When this event is triggered, we check if the k 4 min read How to Simulate a Click in JavaScript? Simulating a click in JavaScript means triggering a click event on an HTML element using code, rather than requiring manual user interaction. This technique is useful for automating actions like clicking buttons, links, or other interactive elements, enhancing web functionality, and triggering hidde 3 min read How to use the alert() method in JavaScript ? In this article, we will learn how to use the alert() method in JavaScript. The alert() method is used to show an alert box on the browser window with some message or warning. We can use it as a message or as a warning for the user. Approach: To show an alert on the browser window, we make a button. 2 min read Create a Music Player using JavaScript As streaming is increasingly being adopted by users, online media players have become essential for consuming media on the internet. Music players allow one to enjoy music in any browser and supports a lot of the features of an offline music player.We will be creating a music player with a clean use 13 min read Like