The JavaScript checked property is easy ✅

preview_player
Показать описание
00:00:00 intro
00:00:22 HTML checkbox
00:01:13 HTML radiobuttons
00:02:58 other HTML elements
00:03:55 CSS
00:04:39 JavaScript constants
00:06:08 .onclick property
00:06:31 .checked property
00:09:49 conclusion

// .checked = property that determines the checked state of an
// HTML checkbox or radio button element

}
else{
}

}
}
}
else{
}
}
Рекомендации по теме
Комментарии
Автор

// .checked = property that determines the checked state of an
// HTML checkbox or radio button element

const myCheckBox =
const visaBtn =
const masterCardBtn =
const payPalBtn =
const mySubmit =
const subResult =
const paymentResult =

mySubmit.onclick = function(){

if(myCheckBox.checked){
subResult.textContent = `You are subscribed!`;
}
else{
subResult.textContent = `You are NOT subscribed!`;
}

if(visaBtn.checked){
paymentResult.textContent = `You are paying with Visa`;
}
else if(masterCardBtn.checked){
paymentResult.textContent = `You are paying with MasterCard`;
}
else if(payPalBtn.checked){
paymentResult.textContent = `You are paying with PayPal`;
}
else{
paymentResult.textContent = `You must select a payment type`;
}
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<input type="checkbox" id="myCheckBox">
<label

<input type="radio" id="visaBtn" name="card">
<label
<input type="radio" id="masterCardBtn" name="card">
<label
<input type="radio" id="payPalBtn" name="card">
<label

<button type="submit"

<p id="subResult"></p>
<p id="paymentResult"></p>

<script src="index.js"></script>
</body>
</html>

body{
font-family: Verdana;
font-size: 2em;
}
#mySubmit{
font-size: 1em;
}

BroCodez
Автор

Bro, this new JS series is just great because it is full of examples and mini project in which we can apply the knowledge to a real situation. Thanks a bunch!

Автор

Thanks for making this series. Without you I would've never successed!
This video was the most useful, that's why I'm commenting on this one lol.

thenoobwhogrinds
Автор

Thanks, bro. You're a real bro 💪

helioobianchi
Автор

I can't believe I missed this video.
I made a little test and I used a long code and it took me two weekends and I wish I known the checked property then,
I never was a great student i guess, this weekend I will try to do a quiz project with the checked property to practice.
Mr Bro you are doing a service, thank you.

ihabmidhat
Автор

You are a real Bro to us . We love you 😘

rajushah
Автор

<*_> This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal. <_*>

piotrmazgaj
Автор

Incredible - I'm going through each video. thank you so much.

christophertucciarone
Автор

This is exactly the way I can understand js.

SayeGhaderi
Автор

"All the heros don't wears cap,
some also teach coding."

furqan-xyz
Автор

I made a page with very similar code as yours and for some reason the all the const variables were not needed. Is this something new?

mindlessmeat
Автор

you're doing good videos I like it

peschkeraphel
Автор

what is in the last code on the PayPal in JavaScript the wont show as you are paying with PayPal i do have the whole code typed up right but the last bit does not want to work

mantaskarpas
Автор

Magic!
Clear radio buttons on page refresh:
window.onload = function () {
let radios =
radios.forEach(function (radio) {
radio.checked = false;
});
};

alan-overthenet
Автор

If you nest the paymentResult ladder in subReasult it'll be even better.

aritranayek
join shbcf.ru