Created
October 29, 2016 02:22
-
-
Save jbugcoder/1ef5b9101e220191c13736312a50ac62 to your computer and use it in GitHub Desktop.
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
<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