-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtema2.html
37 lines (33 loc) · 1.22 KB
/
tema2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.min.js"></script>
<title>Tema 2</title>
</head>
<body>
<h1>Tema 2</h1>
<!-- Div para mostrar el bloque de código -->
<div id="codeBlock" class="language-javascript">
<pre><code class="language-javascript">function saludar() {
console.log("¡Hola, mundo!");
}</code></pre>
</div>
<button id="cargarCodigo">Cargar Código</button>
<script>
// Función para insertar el bloque de código
function insertarCodigo() {
const codeBlock = `
<pre><code class="language-python">def saludar():
print("¡Hola, mundo!")</code></pre>
`;
document.getElementById("codeBlock").innerHTML = codeBlock;
Prism.highlightAll();
}
// Asociar la función al botón
document.getElementById("cargarCodigo").addEventListener("click", insertarCodigo);
</script>
</body>
</html>