How do I disable the radio button using JavaScript?
Disable property in JavaScript
The disabled property returns whether a radio button should be disable or not. A disable element is unsuable and un-clickable.
Syntax:- radioObject.disabled
set the disable property:-radioObject.disable = false\true
- True :- The radio button is disable.
- False :- The radio button is not disable.
Let’s See an example of it:-
- <!DOCTYPE html>
- <html>
- <body>
- Radio Button: <input type="Radio" id="myRadio"><br>
- <p> click the "submit" button to disable the radio button.</p>
- <button onclick="myFunction()">submit</button>
- <script>
- function myFunction(){
- document.getElementById("myRadio").disabled = true;
- }
- </script>
- </body>
- </html>
Comments
Post a Comment