Skip to content

Commit 678ced0

Browse files
authored
Merge pull request #31 from josemoracard/jose3-04-hide-on-click
exercises 04-hide-on-click a 08-event-target
2 parents 92af6e6 + 64be5c7 commit 678ced0

File tree

32 files changed

+219
-73
lines changed

32 files changed

+219
-73
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>4Geeks Academy</title>
7+
</head>
8+
<body>
9+
<button onclick="myClickFunction();">Click me</button>
10+
and
11+
<button onclick="myClickFunction();" id="button2">Don't click me</button>
12+
<script src="index.js"></script>
13+
</body>
14+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>4Geeks Academy</title>
7+
</head>
8+
<body>
9+
<input onclick="myClickFunction();" id="hello" type="button" value="Press to show 'Hello world'" />
10+
<script src="index.js"></script>
11+
</body>
12+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Declare your function here
2+
function myClickFunction() {
3+
alert("Hello World");
4+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Adding the function to the window makes it globally available
2+
window.calculateSumListener = function() {
3+
// Return the value of the input #firstNumber
4+
let stringA = document.getElementById("firstNumber").value;
5+
// Return the value of the input #secondNumber
6+
let stringB = document.getElementById("secondNumber").value;
7+
// Your code here
8+
let sum = parseInt(stringA) + parseInt(stringB);
9+
let resultInput = document.getElementById("resultNumber");
10+
resultInput.value = sum;
11+
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `04` Oculta onclick
1+
# `04` Hide onclick
22

33
## 📝 Instrucciones:
44

@@ -7,4 +7,4 @@
77

88
## 💡 Pista:
99

10-
Para ocultar un elemento en javascript debes usar **element.style.display**
10+
+ Para ocultar un elemento con JavaScript debes usar `element.style.display`, y establece el valor correcto.

exercises/04-hide-on-click/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
## 💡 Hint:
88

9-
To hide an element with javascript your need to do **element.style.display**
9+
+ To hide an element with JavaScript you need to do `element.style.display`, then set it with the correct value.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
window.myEventListener = function myEventListener()
2-
{
3-
//your code here
1+
window.myEventListener = function myEventListener() {
2+
// Your code here
3+
44
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
window.myEventListener = function myEventListener() {
2+
// Your code here
3+
let firstDiv = document.querySelector('#firstDiv')
4+
firstDiv.style.display = "none"
5+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# `05` El evento load
1+
# `05` The load Event
22

33
Es una muy buena práctica esperar a que el navegador termine de cargar la página antes de iniciar el flujo de tu sitio web/aplicación, para hacerlo, usamos el evento LOAD.
44

55
## 📝 Instrucciones:
66

7-
1. Crea una función llamada `loadListener` que escuche al evento `load` y luego muestre una alerta con el string "loading finished..." cuando se la llame.
7+
1. Crea una función llamada `loadListener` que escuche al evento `load` y luego muestre una alerta con el string "Loading finished..." cuando se la llame.
88

9-
## 💡 Pista:
9+
## 💡 Pistas:
1010

1111
- El listener debe asignarse al body.
1212

13-
- Así se añade un listener de evento a un evento load: http://www.w3schools.com/jsref/event_onload.asp
13+
- Así se añade un listener de evento a un evento load: http://www.w3schools.com/jsref/event_onload.asp

exercises/05-the-load-event/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
It is a very good practice to wait for the browser to finish loading the page before starting the flow of your website/application, to do so, we use the LOAD event.
44

5-
## 📝 Instructions
5+
## 📝 Instructions:
66

7-
1. Create a function called `loadListener` that listens to the `load` event and alerts the string "loading finished..." when called.
7+
1. Create a function called `loadListener` that listens to the `load` event and triggers an alert with the string "Loading finished..." when called.
88

9-
## 💡 Hint:
9+
## 💡 Hints:
1010

1111
- The listener has to be assigned to the body.
1212

13-
- Here is how to add the event listener to the load event: http://www.w3schools.com/jsref/event_onload.asp
13+
- Here is how to add the event listener to the load event: http://www.w3schools.com/jsref/event_onload.asp

0 commit comments

Comments
 (0)