编辑下面的代码:【加编码】
<html> <body> 生日: <input type="date" id="myDate"> <p>点击按钮设置 date 字段为只读。</p> <p><strong>提示:</strong> 为了查看效果,你可以先点击 date 字段设置日期,然后点击按钮。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myDate").readOnly = true; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂