HTML DOM Input Radio checked प्रॉपर्टी टाइप radio वाले <input> एलिमेंट के checked प्रॉपर्टी से जुड़ी होती है। इसका उपयोग मूल रूप से रेडियो बटन के checked एट्रिब्यूट मान को सेट या प्राप्त करने के लिए किया जाता है।
सिंटैक्स
Checked प्रॉपर्टी सेट करने के लिए सिंटैक्स:
radioObject.checked = true|false
उदाहरण
Radio checked प्रॉपर्टी का एक उदाहरण:
<!DOCTYPE html> <html> <body> <h1>Input Radio checked प्रॉपर्टी</h1> <form> FRUIT: <input type="radio" name="fruits" id="Mango">Mango <input type="radio" name="fruits" id="Apple">Apple </form> <br><button type="button" onclick="checkApple()">Apple चेक करें</button> <script> function checkApple() { document.getElementById("Apple").checked = true; } </script> </body> </html>
आउटपुट
उपरोक्त कोड से निम्न आउटपुट प्राप्त होगा:

"Apple चेक करें" बटन पर क्लिक करने पर:

उपरोक्त उदाहरण में:
हमारे पास एक फॉर्म के अंदर दो इनपुट फील्ड हैं जिनमें सामान्य एट्रिब्यूट type="radio" और name="fruits" हैं। पहले रेडियो बटन की id "Mango" और दूसरे की id "Apple" है:
<form> FRUIT: <input type="radio" name="fruits" id="Mango">Mango <input type="radio" name="fruits" id="Apple">Apple </form>
फिर हमने एक बटन "Check Apple" बनाया जो यूज़र द्वारा क्लिक किए जाने पर checkApple() मेथड को एक्जीक्यूट करेगा:
<button type="button" onclick="checkApple()">Check Apple</button>
checkApple() मेथड getElementById() मेथड का उपयोग करके टाइप रेडियो वाले इनपुट एलिमेंट को प्राप्त करता है और इसकी checked प्रॉपर्टी को true पर सेट करता है। यह apple रेडियो बटन को चेक करता है:
function checkApple() { document.getElementById("Apple").checked = true; }