to be ressamblance with the example, I just give some personal style to don't be the same colors pallete
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calendar</title>
<style>
body {
font: normal 1.7em Arial ;
}
ul {
width: 600px;
}
li {
width: 100px;
height: 30px;
display: inline-block;
background-color: blueviolet;
margin: 2px;
font: normal 30px Arial;
color: blanchedalmond;
border-radius: 3em;
border: 5px groove pink;
}
select {
width: 100px;
height: 30px;
border-radius: 3em;
border: 5px groove pink;
background-color: blueviolet;
}
</style>
</head>
<body>
<h2>Calendar</h2>
<select name="" id="months">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="Octomber">Octomber</option>
<option value="November">November</option>
<option value="Dezembro">Dezembro</option>
</select>
<ul></ul>
<h1></h1>
<script>
const select = document.querySelector('select');
const list = document.querySelector('ul');
const h1 = document.querySelector('h1');
select.addEventListener('change', ()=>{
let month = select.value;
h1
let days= 31;
switch (month) {
case 'February':
days = 28;
break;
case 'April':
days = 30;
break;
case 'June':
days = 30;
break;
case 'September':
days = 30;
break;
case 'November':
days = 30;
break;
default :
days = 31;
}
createCalendar(days,month);
})
function createCalendar(days,month) {
list.innerHTML = '';
h1.textContent = month+','+days;
for(let i=1; i <= days; i++){
const listItem = document.createElement('li');
listItem.textContent = i;
list.appendChild(listItem);
}
}
createCalendar(31, 'January');
</script>
</body>
</html>
Rute Bezerra de Menezes Gondim
No comments:
Post a Comment