jquery 基于单选按钮启用/禁用文本框
在我的页面(jsp)中,我有一个单选按钮组和一个文本框(最初被禁用)。
- 每当用户单击单选按钮时,文本框都应启用
- ,而当用户单击其他单选按钮时,文本框应再次禁用。
我可以使用下面的代码启用最初禁用的复选框。
$("#DevGroup_OTHER").click(function(){
$("#otherDevText").attr("disabled","");
})
我的问题:
- 但是我怎样才能再次禁用文本框?
- 有没有更简单的使用 jQuery 的解决方案?
问候
In my page (jsp) i have a radiobutton group and a textbox (which is disabled initially).
- Whenever the user clicks on a radio button the textbox should be enabled
- and when the user clicks on some other radio button the textbox should again get disabled.
I am able to enable the initially disabled checkbox with the code below.
$("#DevGroup_OTHER").click(function(){
$("#otherDevText").attr("disabled","");
})
My questions:
- But how can i disable the textbox again?
- Is there a simpler solution using jQuery?
regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
始终禁用它(对于每个单选按钮),如果单选按钮是启用文本框的单选按钮,则重新启用它。除非用户使用的是 1980 年制造的机器,否则速度会如此之快,没有人会知道。
或者,如果有多个单选按钮将启用文本框:
有道理吗?
Always disable it (for every radio button), then re-enable it if the radio button is the one that enables the textbox. Unless the user is on a machine built in 1980, it will be so fast, not one will ever know.
Alternatively, if there are multiple radio buttons that will enable the textbox:
Make sense?