Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.