x
 
<!DOCTYPE html>
<html>
<body>
密码:<input type="password" id="myPsw" readonly>
<p>单击该按钮可查看密码字段是否为只读。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myPsw").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>