hamed Jafarian
Coder
i want my button created inside the div with display grid. so you have 8 buttons in every row. its for my Javascript homework.
HTML:
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test exc10</title>
<style>
.btnn {
background: white;
border: 1px solid black;
border-radius: 10px;
width: 80px;
margin: 5px;
display: flex;
align-items: center;
}
.container {
display: grid;
grid-template-columns: auto auto auto auto auto auto auto auto;
}
</style>
</head>
<body>
<p>لطفا زمان مورد نظر برای مراجعه به مطب را انتخاب نمایید :</p>
<div class="container"></div>
<script>
for (let h = 8; h <= 20; h++) {
for (let m = 0; m < 60; m += 15) {
let time = h;
time = time + ":" + m;
if (m == 0) {
time += 0;
}
const btn = document.createElement("button");
btn.setAttribute("class", "btnn");
btn.innerHTML = ("<br>" + "<input type='radio' name='rad'>" + time);
document.body.appendChild(btn);
}
}
</script>
</body>
</html>
Last edited by a moderator: