JS/JQuery 设置input等标签设置和取消只读属性

时间:2024-04-17 23:27:24
<input type="text" id="HouseName" value="" align="left"/>

<script>
  //js方式:js对大小写敏感
   document.getElementById("HouseName").readOnly = true;  //设置只读 //readOnly 大小写敏感
  document.getElementById("HouseName").readOnly = false;  //取消只读   //jquery方式:
  HouseName.attr("readonly","readonly"); //设置为readonly
  HouseName.removeAttr("readonly");    //去除元素的readonly属性 </script>