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"/> 間 <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>