07:31The JavaScript checked property is easy ✅
From the creator
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 const myCheckBox = document.getElementById("myCheckBox"); const visaBtn = document.getElementById("visaBtn"); const masterCardBtn = document.getElementById("masterCardBtn"); const payPalBtn = document.getElementById("payPalBtn"); const mySubmit = document.getElementById("mySubmit"); const subResult = document.getElementById("subResult"); const paymentResult = document.getElementById("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`; } }
Published 2023-10-22 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





