ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
HTML Code: Calculator Calculator Number 1: Number 2: + - x / = CSS Code:body{ background-color: hsl(0, 0%, 95%); font-family: sans-serif;}form{ background-color: hsl(0, 0%, 100%); width: 350px; margin: auto; padding: 25px; border-radius: 10px; box-shadow: 5px 5px 15px hsla(0, 0%, 0%, 0.3);}input{ font-size: 1.1em; margin-bottom: 10px; border-radius: 7px;}label{ font-size: 1.5em; font-weight: bold;}h1{ text-align: center;}button{ background-color: hsl(39, 97%, 57%); color: white; border: none; font-size: 1.5em; padding: 7px 15px; border-radius: 10px; margin-top: 7px;}p{ font-size: 1.75em; font-weight: bold; text-align: center;}JS Code:const num1 = document.getElementById("num1");const num2 = document.getElementById("num2");const add = document.getElementById("add");const sub = document.getElementById("sub");const mul = document.getElementById("mul");const div = document.getElementById("div");const submit = document.getElementById("submit");const result = document.getElementById("result");let x;let y;let z;submit.onclick = function(){ if(add.checked){ x = Number(num1.value); y = Number(num2.value); z = x + y; result.textContent = z; } else if(sub.checked){ x = Number(num1.value); y = Number(num2.value); z = x - y; result.textContent = z; } else if(mul.checked){ x = Number(num1.value); y = Number(num2.value); z = x * y; result.textContent = z; } else if(div.checked){ x = Number(num1.value); y = Number(num2.value); z = x / y; result.textContent = z; } else{ result.textContent = "Choose an option" }}Btw feel free to improve this code and give suggestionsand if you use it make sure to give me credits
btw in css also addbutton:hover{background-color: orange;}and in button also addbutton{cursor: pointer;}
Nice video, keep creating the same video for the beginners
Thanks, btw do you have any ideas ?
@@Football.Legends7654 you can create small projects for all languages that you are familiar with.
@@shor.ts959Ok but currently I'm still learning js so in my next video I will make a counter program as I progress I will make advance things
@@Football.Legends7654 I'll be watching..
HTML Code:
Calculator
Calculator
Number 1:
Number 2:
+
-
x
/
=
CSS Code:
body{
background-color: hsl(0, 0%, 95%);
font-family: sans-serif;
}
form{
background-color: hsl(0, 0%, 100%);
width: 350px;
margin: auto;
padding: 25px;
border-radius: 10px;
box-shadow: 5px 5px 15px hsla(0, 0%, 0%, 0.3);
}
input{
font-size: 1.1em;
margin-bottom: 10px;
border-radius: 7px;
}
label{
font-size: 1.5em;
font-weight: bold;
}
h1{
text-align: center;
}
button{
background-color: hsl(39, 97%, 57%);
color: white;
border: none;
font-size: 1.5em;
padding: 7px 15px;
border-radius: 10px;
margin-top: 7px;
}
p{
font-size: 1.75em;
font-weight: bold;
text-align: center;
}
JS Code:
const num1 = document.getElementById("num1");
const num2 = document.getElementById("num2");
const add = document.getElementById("add");
const sub = document.getElementById("sub");
const mul = document.getElementById("mul");
const div = document.getElementById("div");
const submit = document.getElementById("submit");
const result = document.getElementById("result");
let x;
let y;
let z;
submit.onclick = function(){
if(add.checked){
x = Number(num1.value);
y = Number(num2.value);
z = x + y;
result.textContent = z;
}
else if(sub.checked){
x = Number(num1.value);
y = Number(num2.value);
z = x - y;
result.textContent = z;
}
else if(mul.checked){
x = Number(num1.value);
y = Number(num2.value);
z = x * y;
result.textContent = z;
}
else if(div.checked){
x = Number(num1.value);
y = Number(num2.value);
z = x / y;
result.textContent = z;
}
else{
result.textContent = "Choose an option"
}
}
Btw feel free to improve this code and give suggestions
and if you use it make sure to give me credits
btw in css also add
button:hover{
background-color: orange;}
and in button also add
button{
cursor: pointer;}
Nice video, keep creating the same video for the beginners
Thanks, btw do you have any ideas ?
@@Football.Legends7654 you can create small projects for all languages that you are familiar with.
@@shor.ts959Ok but currently I'm still learning js so in my next video I will make a counter program as I progress I will make advance things
@@Football.Legends7654 I'll be watching..