CSS3 - enabled和disabled

xiaoxiao2021-02-28  50

<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <style> input[type="text"]:enabled{ background-color:gold; } input[type="text"]:disabled{ background-color:dimgrey; } </style> </head> <body> <script> function radio_change(){ var radio1 = document.getElementById('radio1'); var radio2 = document.getElementById('radio2'); var text = document.getElementById('text'); if(radio1.checked){ text.disabled = ""; }else{ text.value = ""; text.disabled = "disabled"; } } </script> <input type="radio" id="radio1" name="radio" onchange="radio_change()" />可用 <input type="radio" id="radio2" name="radio" onchange="radio_change()" />不可用 <input type="text" id="text" disabled /> </body> </html>

转载请注明原文地址: https://www.6miu.com/read-2624210.html

最新回复(0)