Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
# Event-listeners-basics
### Setup
- We included a html file ready to use. You must not modify it for this exercise.
- We also included an image that is ready to be used and included in the <img> from the html file.
- You don't need to use a css stylesheet for this exercise.

### Homework

Your task is to replicate the behaviour from the zoom.mp4 file (go check it!).
To do that you need to:

1. In the javascript file, store the two buttons from the html in two different variables.

2. Store the image in another variable.
To do these steps you can use the name of the id and classes. Here's an example:
```javascript
const variableName = document.querySelector(".class");
const VARIABLE_NAME = document.querySelector("#id");
```

3. Then, you'll need to create one function. This function will use the variable you created to store the image. As you know, images have attributes that can change their size. Go check in the html what attribute you could use that is a numerical one. When you know it, try to add `100` to it inside the function you created.

4. Now let's subtract `100` from that same attribute in another function that zooms out.

5. Super! Now it's time to add the event listeners to our elements. Here's an example:
```javascript
variableName.addEventListener("click", function);
```
Make sure you add one Click listener to the zoom in button, and another Click listener to the zoom out button.

That's it, great job! 🚀
# Event-listeners
21 changes: 21 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Part 1
const ZoomIn = document.querySelector(".zoom-in-btn");
const ZoomOut = document.querySelector(".zoom-out-btn");
//Part 2
const image = document.querySelector("#image");

//Part 3
const increase = () => {
image.width +=100;
};

ZoomIn.addEventListener("click", increase);

const decrease = () => {
image.width -= 100;
};

ZoomOut.addEventListener("click", decrease);