Doors Exercise: Door1 Null Element

I am stuck at the ChoreDoor exercise, choreDoor

I don’t think I am doing anything wrong, please help me I tried all.

Screen Shot 2020-05-07 at 10.56.19 PM|690x314

You may want to review this: https://www.codecademy.com/paths/web-development/tracks/build-interactive-websites/modules/web-dev-interactive-websites/lessons/javascript-dom/exercises/onclick-element

I don’t see the error. :S

You’re using this.src. Is that at all in the lesson about onClick?

Tried both ways, and If you look in the console the problem its that door1 is returning a null, I don’t know how to fix it. css is fine html is fine js is fine.

Proof: https://d.joo.mx/2pyzhC+

Can we see it please?

1 Like

Here I made a video: https://d.joo.mx/fcDZly

<!DOCTYPE html>
<html>
  <head>
    <title>Chore Door!</title>
       <script src="script.js"></script>
    <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 id="door1" src="https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/closed_door.svg" ></div>
  </body>
</html>

let doorImage1 = document.getElementById("door1");

const botDoorPath = "https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg";

doorImage1.onclick = () => {
  doorImage1.src = botDoorPath;
};

Try reviewing task #6.

Hint

There’s a reason the <script></script> tag should be placed where the instructions specify. You’ve seen the outcome. Why do you suppose that is?

1 Like

Thank you! I got this task checked by the system as if it was right, this is why I did not look there. Thank you again :slight_smile:

1 Like

You’re welcome. Do you understand why the location of the <script></script> tag makes a difference?

Also, in this project, you have to mark the tasks off as complete when you finish them. It’s possible that when you click on the instruction panel to scroll down, that the click marks a task as complete. (I accidentally uncheck tasks all the time doing just that. :smile:)