-
-
Save DavidPeralvarez/4bc679ed21b456bd896992b6fc659d55 to your computer and use it in GitHub Desktop.
JavaScript - Introducción a los eventos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Curso de Javascript</title> | |
</head> | |
<body> | |
<!-- <button onclick="miFuncion()">Haz clic aquí</button> | |
<input type="text" name="" onmouseover="entro()" onmouseout="salgo()"> --> | |
<button id="mi-boton">Haz clic aquí</button> | |
<input type="text" name="" id="mi-input"> | |
<script src="scripts.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function miFuncion(){ | |
console.log( 'Ha hecho clic en el botón' ); | |
} | |
function entro(){ | |
console.log( 'entro' ); | |
} | |
function salgo(){ | |
console.log( 'salgo' ); | |
} | |
var boton = document.getElementById( 'mi-boton' ); | |
console.log( boton ); | |
boton.addEventListener( 'click', miFuncion ); | |
var inputText = document.getElementById( 'mi-input' ); | |
console.log( inputText ); | |
inputText.addEventListener( 'mouseover', entro ); | |
inputText.addEventListener( 'mouseout', salgo ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment