Monday, 14 March 2011

How to disable radiobutton list via jQuery?

Using normal JavaScript you have to find all the elements in the radio group, which can be done using document.getElementsByTagName(radiogroupname), and iterate through the list to do this. But it is very simple to do this using jQuery, just one line of code.

Use either

$("*[name$='radiogroupname']").attr("disabled", "true");

or

$("input:radio[name$='radiogroupname']").attr("disabled", "true");

It will disable all the radio buttons in the group.

:) Happy scripting

2 comments: