-2

I study graphics as one of my subjects at school. Currently, my task is to make a website for a party so I have started to create the homepage. The home page has four balloons on it and when you roll over them they pop. But, what I also want them to do is to play a balloon popping sound effect when you roll over them and they pop.

However, I cant work out what the HTML would be to achieve this.

The website: partybox.businesscatalyst.com

  • Please add meaningful code and a problem description here. Don't just link to the site that needs fixing - otherwise, this question will lose any value to future visitors once the problem is solved or if the site you're linking to is inaccessible. Posting a [Minimal, Complete, and Verifiable example (MCVE)](https://stackoverflow.com/help/mcve) that demonstrates your problem would help you get better answers. For more info, see [Something on my web site doesn't work. Can I just paste a link to it?](https://meta.stackexchange.com/questions/125997/) Thanks! – Mrigank Pawagi Jan 03 '18 at 10:55
  • Also, Pure code-writing requests are off-topic on Stack Overflow -- we expect questions here to relate to *specific* programming problems -- but we will happily help you write it yourself! Tell us [what you've tried](https://stackoverflow.com/help/how-to-ask), and where you are stuck. This will also help us answer your question better. – Mrigank Pawagi Jan 03 '18 at 10:55
  • I have tried this code – Alex McIver Jan 03 '18 at 11:14
  • Put the code ***inside*** the answer! – Mrigank Pawagi Jan 03 '18 at 11:16

1 Answers1

0

This cannot be done efficiently using only HTML, as it will require the use of <audio> as in

<audio autoplay>
    <source src="file.wav" type="audio/wav"><!--file.wav will replace your sound file with the pop effect-->
</audio>     

However, the <audio> still required to be started (in case of controls) or dynamically created (in case of autoplay) - which will still require JavaScript.

A simpler JavaScript method would be like - on your onclick or onhover function, simply add this JavaScript Code:

var sound = new Audio("file.wav"); //file.wav will replace your sound file with the pop effect
sound.play(); //Play the sound
Mrigank Pawagi
  • 722
  • 1
  • 7
  • 24