Rollover sound

Mar 15, 2023
Reaction score
To implement a rollover sound for each ahref in a menu.php, you can follow these steps:

  1. Create an audio file: First, you need to create an audio file that will be played when the user rolls over each ahref in the menu. You can use any audio editing software to create the audio file, save it in a compatible audio format (such as MP3 or WAV), and name it something like "rollover-sound.mp3".
  2. Add the audio file to your project: Once you have created the audio file, add it to your project's directory.
  3. Add JavaScript code: Add the following JavaScript code to the head section of your HTML page to play the audio file when the user rolls over each ahref in the menu:

  var audio = new Audio('path/to/rollover-sound.mp3'); // Replace 'path/to' with the actual path to your audio file

  var links = document.getElementsByTagName('a');

  for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('mouseover', function() {;

  1. Save and test: Save the changes to your menu.php file and test the rollover sound by hovering over each ahref in the menu.
Note: In the above code, we are using the getElementsByTagName method to get all the ahref elements in the document and then attaching a mouseover event listener to each of them. When the user rolls over each ahref, the method is called to play the rollover sound.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads