[英]How to disable input readonly in Laravel?
I've a problem in my Laravel project.我的 Laravel 项目有问题。 In a form I've the input with readonly attribute在表单中,我输入了只读属性
<input type="text" name="anamFam" id="anamFam" value="{{$aFam->anam_cont}}" readonly>
and when I press the button edit I need to disable or remove the readonly attribute.当我按下按钮编辑时,我需要禁用或删除只读属性。 So I try to use javascript in this way所以我尝试以这种方式使用javascript
function edit() {
document.getElementById('anamFam').readOnly=false;
}
Or using this in js:或者在 js 中使用它:
document.getElementById('anamFamiliare').removeAttribute('readonly')
And in jQuery I tried in this way在 jQuery 中,我以这种方式尝试过
$(document).ready(function ( e) {
$(document).on("click", "#edit", function (e) {
$(':input').removeAttr('readonly')
})
})
Or using this in jQuery:或者在 jQuery 中使用它:
$(':input').prop('readonly',false)
So when I click the button something happens as the input border become black, but when I try to edit in the input I can't edit as the pointer doesn't appear.因此,当我单击按钮时,输入边框变黑时会发生一些事情,但是当我尝试在输入中进行编辑时,由于没有出现指针,因此无法进行编辑。 So what is the problem那么问题是什么
EDIT编辑
I solved using disabled
attribute我使用disabled
属性解决了
In your jQuery code, use the following line instead of what you are using在您的 jQuery 代码中,使用以下行而不是您正在使用的
$("#anamFam").attr("readonly", false);
Hope it works.希望它有效。
for your scenario, it would be something like this:对于您的场景,它会是这样的:
$(document).ready(function(){
$('#edit').click(function(){
$("#anamFam").attr("readonly", false);
});
});
onclick="document.getElementById('awake_morning_{{$el->id}}').readOnly=false"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.