Last active
August 29, 2015 14:07
-
-
Save eamexicano/44de12a34c33480d06d8 to your computer and use it in GitHub Desktop.
Cargar scripts de distintas carpetas y ejecutarlos al momento.
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'> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Ejercicios</title> | |
<link rel="stylesheet" href="estilo.css" type="text/css"> | |
</head> | |
<body> | |
<h2>Ejercicios disponibles</h2> | |
<div id='mensaje'> | |
<p> | |
Selecciona un botón para revisar un ejercicio. | |
</p> | |
</div> | |
<button>clase01/ejercicio01.js</button> | |
<button>clase02/ejercicio01.js</button> | |
<button>clase02/ejercicio02.js</button> | |
<button>clase02/ejercicio03.js</button> | |
<button>clase02/ejercicio04.js</button> | |
<button>clase02/ejercicio05.js</button> | |
<button>clase02/ejercicio06.js</button> | |
<button>clase02/ejercicio07.js</button> | |
<button>clase02/ejercicio08.js</button> | |
<button>clase03/ejercicio01.js</button> | |
<script> | |
var botones = document.getElementsByTagName('button'); | |
var mensaje = document.getElementById('mensaje'); | |
var script_a_ejecutar = ""; | |
function cargar_ejercicio() { | |
mensaje.innerHTML = "<p>Revisando: " + this.textContent + "</p>"; | |
script_a_ejecutar = document.createElement('script'); | |
script_a_ejecutar.setAttribute('src', this.textContent); | |
mensaje.appendChild(script_a_ejecutar); | |
} | |
(function () { | |
for (var i = 0; i < botones.length; i++) { | |
botones[i].addEventListener('click', cargar_ejercicio); | |
} | |
}()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment