x
 
<!DOCTYPE html>
<html>
<body>
电子邮件:<input type="email" id="myEmail">
<p>单击按钮可将电子邮件字段设置为只读。</p>
<p><b>提示:</b>如需查看效果,请尝试在单击按钮前后在电子邮件字段中键入内容。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("myEmail").readOnly = true;
}
</script>
</body>
</html>