I have a method in Javascript
that creates a table of 0 a 99
, and I have a vector that goes from 1 a 5
. The idea of the script would be that every time the table number was the same as the vector, the table number was painted. I can not do this and would like some help. I apologize if my question was not very clear follow the code below:
JS
var vetor = [1, 2, 3, 4, 5];
function o() {
var n;
n = 0;
for (var l = 0; l < vetor.length; l++) {
document.write("<table>");
for (j = 0; j < 10; j++) {
document.write("<tr>");
for (i = 0; i < 10; i++) {
if (vetor[l] == n) {
document.write("<td>" + "<mark>" + n++ + "</mark>" + "</td>");
} else {
document.write("<td>" + n++ + "</td>");
}
}
document.write("</tr>");
}
document.write("</table>");
}
}
CSS
table, td, tr {
border: solid grey 1px;
}
HTML
<head>
<meta charset="utf-8">
<title> </title>
</head>
<body>
<button onclick="o();">teste</button>
<p id="1"></p>
</body>
</html>