Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
Created April 15, 2020 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidPeralvarez/4bc679ed21b456bd896992b6fc659d55 to your computer and use it in GitHub Desktop.
Save DavidPeralvarez/4bc679ed21b456bd896992b6fc659d55 to your computer and use it in GitHub Desktop.
JavaScript - Introducción a los eventos
<!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>
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