Open finchmar opened 7 years ago
Really good job on this project. It functions great, there's one small request I'd like to make of the JavaScript in your HTML. 🥁
Can you remove the onclick="Sound1()"
code in your HTML and give each button an ID so you can do something like this:
document.getElementById('boomButton').addEventListener('click', function () {
Sound1()
})
Putting all of your JavaScript in a separate file (including adding event handlers) means a designer can worry about the HTML without breaking the code, and a developer can change the code without worrying about accidentally changing the appearance or content of the site.
addEventListener
is also more flexible than onclick="..."
because you can use addEventListener
to add multiple event handlers to an element.
After you’ve made your changes and pushed them to GitHub and your hosted site, give it a once-over to make sure it looks right, then comment back here and I’ll take another look.
Thanks! :rocket:
fix it!
Awesome, thanks! :shipit:
@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