我有一个从php文件创建的表单和一个文本字段,它有一个只读属性,点击编辑按钮(编辑按钮也是在创建输入字段的过程中创建的),我希望所述字段是可编辑的,我该怎么做?
<td text align="center">
<input type="text" id=SOME_AMOUNT<?= $j; ?> value=<?=" " .$arr[$j]['BILL_AMOUNT'] . " "; ?> readOnly>
<button type="button" id=EDIT_AMOUNT<?php echo "$j"; ?> class="EDIT_AMOUNT btn btn-mini btn-primary"> Edit Bill</button>
$(document).ready(funcion(){
$(".EDIT_AMOUNT").click(function(){
var id=$(this).attr('id');
var index=id.match(/'d+$/)[0]; // to get the id numerals from the id string
$("#SOME_AMOUNT"+index).attr("readOnly", false);
});
});
编辑:问题似乎在于php文件中包含的用于表对齐的javascript。。这怎么可能?
试试这个(纯JS):
document.getElementById('SOME_AMOUNT').readonly = false;
使用此
$("#SOME_AMOUNT"+index).attr('readOnly', false);
或
$("#SOME_AMOUNT"+index).removeAttr('readOnly');
您可以在jquery:中尝试此操作
$('element').attr('some attribute','some attributes value')
在你的情况下,它会是:
$('you_elemnt').attr("readOnly", false);
您需要删除该属性;
$("#SOME_AMOUNT"+index).removeAttr('readonly');
试试这个
$('#FullName').attr('readOnly', false);
或者试试这个
$('#FullName').removeAttr('readonly');