<html>
<body>
生日: <input type="datetime" id="myDatetime">
<p>点击按钮设置 datetime 字段为只读。</p>
<p><strong>提示:</strong> 为了查看效果,你可以再点击按钮前和点击按钮后在表单中填写内容。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myDatetime").readOnly = true;
}
</script>
</body>
</html>