保存更改后启用只读文本框(Enable readonly textbox after saving changes)

[db:摘要]

保存更改后启用只读文本框(Enable readonly textbox after saving changes)

我有一些可在同一页面编辑的表单。 每个文本框的第一个属性是只读的,当我按下编辑按钮时,它将变为可编辑的,使用此语法

$('input[readonly="readonly"]').removeAttr("readonly").prop("enabled",true);

当我按下保存按钮时,我希望它再次成为只读状态。 我试图改变它

$('input[readonly="readonly"]').attr("readonly").prop("disable",true); and $('input[readonly="readonly"]').attr("readonly").prop("readonly",true);

但它不会再变成只读。

有没有正确的方法来做到这一点?

I have some form which is editable in the same page. First attribute for each textbox is readonly, and when I press the edit button, it will become editable, using this syntax

$('input[readonly="readonly"]').removeAttr("readonly").prop("enabled",true);

when i press the save button, i want it become readonly again. I've trying to change it to

$('input[readonly="readonly"]').attr("readonly").prop("disable",true); and $('input[readonly="readonly"]').attr("readonly").prop("readonly",true);

but it won't change into readonly again.

Is there any proper way to do this?

最满意答案

按下编辑按钮时删除了只读属性。

所以, $('input[readonly="readonly"]')与任何东西都不匹配。


例如,

$('input[type="text"]').attr("readonly", "readonly");

将所有文本框设置为只读。

readonly attributes was removed when you press the edit button.

so, $('input[readonly="readonly"]') doesn't match anything.


For example,

$('input[type="text"]').attr("readonly", "readonly");

will set all textboxes to readonly.

发布者:admin,转转请注明出处:http://www.yc00.com/web/1690546459a367697.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信