Skip to content

Instantly share code, notes, and snippets.

@jbugcoder
Created October 29, 2016 02:22
Show Gist options
  • Save jbugcoder/1ef5b9101e220191c13736312a50ac62 to your computer and use it in GitHub Desktop.
Save jbugcoder/1ef5b9101e220191c13736312a50ac62 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
* {
font-size: 15px;
color: #ccc;
}
th, td {
padding: 20px;
text-transform: uppercase;
text-align: center;
}
thead tr {
background-color: #000033;
}
tbody tr {
background-color: blue;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>indice</th>
<th>nome</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
<script>
var cidade;
var indice = 0;
var table = document.getElementById("tbody");
var html = "";
function inserir() {
indice++;
cidade = prompt("insira a cidade");
if ( cidade != null ) {
html += "<tr><td>" + indice + "</td>";
html += "<td>" + cidade + "</td></tr>";
table.innerHTML = html;
inserir()
}
}
inserir()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment