I’ve been working on the Chore Door Project and can’t seem to figure out why the door won’t open. I’ve watched the tutorial video and still can’t seem to detect what’s wrong with my code. Thank you in advance for the help!
Door was opening at step 10 when it was single.
I ran the code on another compiling platform the error was ‘error: Uncaught TypeError: Cannot set property ‘onclick’ of null’
<!DOCTYPE html>
<html>
<head>
<title>Chore Door!</title>
<link href="./style.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Work+Sans" rel="stylesheet" type="text/css">
</head>
<body>
<div class='door-row'>
<img class='door-frame' id='#door1' src='https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg'>
<img class='door-frame' id='#door2' src='https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg'>
<img class='door-frame' id='#door3' src='https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg'>
</div>
</body>
<script type="text/javascript" src="script.js"></script>
</html>
let d= document;
let doorImage1 = d.getElementById('door1');
let doorImage2 = d.getElementById('door2');
let doorImage3 = d.getElementById('door3');
let botDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg';
let beachDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/beach.svg';
let spaceDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/space.svg';
doorImage1.onclick = () => {
doorImage1.src = botDoorPath;
};
doorImage2.onclick = () => {
doorImage2.src = beachDoorPath;
};
doorImage3.onclick = () => {
doorImage3.src = spaceDoorPath;
};
I’ve tried other solutions to this including ‘defer’, calling script after body etc