Closed amanuel1995 closed 7 years ago
The reason the sounds aren't playing is because you have absolute paths (e.g. /drum-sounds/boom.wav
). If you get rid of the leading /
then they should start playing.
But wait! There are a couple of criteria that you missed, too:
audio
elementInstead of using JavaScript to create new Audio()
objects, we want you to define the sounds in audio
elements in your HTML. The audio
element allows a separate web designer to change the content of your site while a web developer changes the functionality. The audio
element also has better capabilities when it comes to unsupported browsers, accessibility, etc.
.js
You're off to a good start, but you still have JavaScript in your HTML. Replace each onclick="Boom()" onmouseover="Boom()"
with document.getElementById(...)
, element.addEventListener('click')
, and element.addEventListener('mouseenter')
. The instructions for doing this are in the lesson. :wink:
After you’ve made your changes and pushed them to GitHub and your hosted site, comment back here and I’ll take another look.
Thanks! :rocket:
@egillespie ,Thank you for the elaborate feedback. It was very helpful. I think I have completed it. Let me know what more I could do. (If there is any )
It looks and works great! :shipit:
I do have a couple of tips, but nothing you need to change for this lesson:
document.getElementById('first').addEventListener('click', Boom)
Thanks for the tips @egillespie! It's always nice to have a cleaner code. 👍 💯
@egillespie Can you take a look at this? It's hosted here and meets the following criteria:
button
elements are included in your pagemouseenter
event) or clicked on (click
event), a unique sound effect plays from anaudio
element (try the.play()
method) -- you may use these drum kit sounds, create ones from this sound effects generator, or use any other sounds that won't hurt/irritate the people who listen to themaudio
elements are invisible (nocontrols
attribute), so that they can only be played with the buttons.js