-1
function tabuada() {
let num = document.getElementById('txtn')
let tab = document.getElementById('seltab')
if (num.value.length == 0) {
window.alert('Por favor,digite um número!')
} else {
let n = Number(num.value)
let c = 1;
tab.innerHTML = ''
while (c <= 10) {
let item = document.createElement('option')
item.text =`${n} x ${c} = ${num*c}`
tab.appendChild(item)
c++
}
}
}
body{
background: rgb(151, 158, 46);
font: normal 15pt Arial;
}
header{
color:white;
text-align: center;
}
section{
background: white;
border-radius:10px;
padding: 15px;
width: 500px;
margin: auto;
box-shadow: 5px 5px 10px rgb(233, 230, 72);
}
footer{
color:white;
text-align: center;
font-style: italic;
}
<!DOCTYPE html>
<html lang="en">
<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">
<title>Tabuada online em js</title>
<link rel="stylesheet" href="estiloTabuada.css"><!--presionar ctrl e clicar para gerar a sugestão de criar um arquivo css-->
</head>
<body>
<header>
<h1>Tabuada!</h1>
</header>
<section>
<div>
<p>Número: <input type="number" name="num" id="txtn">
<input type ="button" value="Gerar Tabuada" onclick="tabuada()">
</p>
</div>
<div>
<select name="Tabuada" id="seltab"></select>
<option>Digite um número acima</option>
</div>
</section>
<footer>
<p>©Yvan.</p>
</footer>
<script src="scriptTabuada.js"></script>
</body>
</html>
And what would be your doubt?
– fernandosavio