Skip to content

Instantly share code, notes, and snippets.

@jreyes
Created April 21, 2018 16:58
Show Gist options
  • Save jreyes/402381766754a3a32d3407d353de082a to your computer and use it in GitHub Desktop.
Save jreyes/402381766754a3a32d3407d353de082a to your computer and use it in GitHub Desktop.
Documento sin título // source https://jsbin.com/murafifife
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>
<body>
<p><img src="http://media.comicbook.com/2018/03/vegeta4-1092189.jpeg"></p>
<script>
function aviso1() {
alert("hola soy la imagen");
}
function aviso2() {
alert("Hola soy el parrafo");
}
function loseventos() {
document.getElementsByTagName('p')[0].onclick = aviso1;
document.getElementsByTagName('img')[0].onclick = aviso2;
}
window.addEventListener("DOMContentLoaded", loseventos, false);
</script>
<script id="jsbin-source-html" type="text/html"><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
</head>
<body>
<p><img src="http://media.comicbook.com/2018/03/vegeta4-1092189.jpeg"></p>
<script>
function aviso1() {
alert("hola soy la imagen");
}
function aviso2() {
alert("Hola soy el parrafo");
}
function loseventos() {
document.getElementsByTagName('p')[0].onclick = aviso1;
document.getElementsByTagName('img')[0].onclick = aviso2;
}
window.addEventListener("DOMContentLoaded", loseventos, false);
<\/script>
</body>
</html>
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment