Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTobi Oluseye
19,884 PointsWhy isn't the audio working for my Wheel and keys?
<!DOCTYPE> <html lang="en"> <head> <meta charset="utf-8"> <link href="style.css" rel="stylesheet"> <title>Practicing my Java</title>
</head>
<body> <img src="images/car1.png" class="car" alt="car"> <a href="javascript:StartCar();"><img src="images/key.png"></a> <a href="javascript:StartHorn();"><img src="images/steering-wheel.png"></a> <a href="javascript:StartNos();"><img src="images/nos.png"></a>
<audio id="StartCar" src="sounds/startCar.wav" preload="auto"></audio>
<audio id="StarHorn" src="sounds/honkHorn.wav" preload="auto"></audio>
<audio id="StartNos" src="sounds/peelOut.wav" preload="auto"></audio>
<script>
function StartCar() { document.getElementbyId('StartCar').play();}
function StartHorn() { document.getElementbyId('StartHorn').play();}
function StartNos() { document.getElementById('StartNos').play();}
</script>
</body>
</html>
This is the code I wrote and when I try the audio only the StartNos one works, why is that? I can't see why the other 2 aren't working
2 Answers
Steven Parker
231,248 PointsThe other two have getElementbyId
with a lower case "b".
It must be spelled getElementById
(with upper case "B") to work.
Simon Coates
28,694 Pointsyou dropped the second t in start on the ids.
Tobi Oluseye
19,884 PointsOh thanks, fixed that now, still only the StartNos works What else is wrong with it?