Search code examples
jqueryradio-buttonsiblings

On check, disable all others


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!


Solution

  • 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