jquery 修改input输入框的 readOnly属性 && input输入框隐藏

时间:2021-12-06 21:45:05
html的代码

                    <div class="control-group">
<label class="control-label required"> <span
class="help-inline"><font color="red">*</font> </span>房间总数:
</label>
<div class="controls">
<input type="text" name="count" id="quantity1"
style="width: 30px;" onchange="totalRooms(1)"
onkeyup="this.value=this.value.replace(/[^\d]/g,'') "
value=""
readOnly="true"/> &nbsp; 间&nbsp;&nbsp;&nbsp;&nbsp; <input class="btn btn-primary" type="button" value="修改总数"
onclick="editCount(1)" />
</div>
</div>

js

<script type="text/javascript">
function editCount(i) {
//$("#quantity"+i).setAttribute("readOnly", false);
//$("#quantity"+i).readOnly=false;
$("#quantity"+i).removeProp("readOnly");
} </script>

注释的前两种不可用,不知道原因,最后的removeProp可用

input输入框隐藏

        <span >
<input value="${roomTypeList }" name="type" style="display:none;"/>
<input value="${str }" name="str" style="display:none;"/>
</span>