Created
March 23, 2015 22:00
-
-
Save AitorAlejandro/85e94c0eb4dae4817c93 to your computer and use it in GitHub Desktop.
Averiguar el elemento que lanza la funcion - cross browser
This file contains hidden or 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
//Ante dos elementos que llaman a la misma funcion: | |
document.getElementById('elem1').onchange = validarInput; | |
document.getElementById('elem2').onchange = validarInput; | |
function validarInput(e){ | |
var oEvent = e || window.event; | |
var elem = oEvent.target || oEvent.srcElement; | |
//En el caso de que elem1 o elem2 sean inputs de un formulario se podria: | |
alert(elem.name); //atributo name del input | |
alert(elem.value); //atributo value del input | |
// etc. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment