检查后,禁用所有其他

发布于 2024-09-15 02:51:41 字数 158 浏览 5 评论 0原文

HTML:

form
  input:radio 1
  input:radio 2
  input:radio 3

如果单击其中之一,我想禁用其余部分。我认为这里将使用兄弟选择器,但我不知道如何使用。

感谢您的帮助!

HTML:

form
  input:radio 1
  input:radio 2
  input:radio 3

If one of these is clicked, I'd like to disable the rest. I think siblings selector will be used here but I can't figure out how.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没有你我更好 2024-09-22 02:51:41

我认为您正在尝试禁用其他功能,为此您需要设置无线电输入的disabled=disabled 属性。

$("input:radio").click(function() {
  $(this).siblings("input:radio").attr("disabled","disabled");
});

示例如下: http://jsbin.com/oquse/2
在此处查看/编辑代码:http://jsbin.com/oquse/2/edit

I think you're trying to disable the others, and for that you need to set the disabled=disabled attribute of the radio input.

$("input:radio").click(function() {
  $(this).siblings("input:radio").attr("disabled","disabled");
});

Example Here: http://jsbin.com/oquse/2
View/Edit Code Here: http://jsbin.com/oquse/2/edit

烧了回忆取暖 2024-09-22 02:51:41

您可以使用简单的 javascript + HTML dom 来执行此操作。

单选按钮事件: http://www.hscripts.com/tutorials/ javascript/dom/radio-events.php

使用 JavaScript 函数在 onClick 事件上激活

you can use simple javascript + HTML dom for doing this.

radio button events: http://www.hscripts.com/tutorials/javascript/dom/radio-events.php

use a javascript function to be activated on onClick event

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文