Created
July 26, 2019 17:25
-
-
Save anthony17guty/3ca6ebe31c227c76b93b0b538bd4c625 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | |
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<title>Ejemplo de tabla</title> | |
</head> | |
<body> | |
<table id="tabla" class="table"></table> | |
</body> | |
<script> | |
//codigo objeto | |
class Heroe { | |
constructor(id, nombre, apellido) { | |
this.id = id; | |
this.nombre = nombre; | |
this.apellido = apellido; | |
this.email = ""; | |
//Métodos | |
this.toString = toString; | |
function toString() { | |
return "Id: " + this.id + ", Nombre: " + this.nombre | |
+ " " + this.apellido; | |
} | |
} | |
} | |
//codigo heroes | |
var heroes = [ | |
new Heroe(1, "Locoman", "Presto"), | |
new Heroe(2, "Precioman", "Artenas"), | |
new Heroe(3, "Kratos", "Melena"), | |
new Heroe(4, "Spidrman", "Parker"), | |
new Heroe(5, "superman", "Ken"), | |
]; | |
//for | |
//ternuritas | |
for (let i = 0; i < heroes.length; i++) { | |
var tr = document.createElement('tr'); | |
var td1 = document.createElement('td'); | |
td1.appendChild(document.createTextNode(heroes[i].id)); | |
tr.appendChild(td1); | |
var td2 = document.createElement('td'); | |
td2.appendChild(document.createTextNode(heroes[i].nombre)); | |
tr.appendChild(td2); | |
var td3 = document.createElement('td'); | |
td3.appendChild(document.createTextNode(heroes[i].apellido)); | |
tr.appendChild(td3); | |
tabla.appendChild(tr); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment