2

If I apply buttonset to a list of checkboxes using JQuery UI, how do i then disable a single checkbox from the list?

HTML

<div id="options">
    <input id="one" type="checkbox" value="1"/><label for="one">One</label>
    <input id="two" type="checkbox" value="2"/><label for="two">Two</label>
</div>

Javascript

    $('#options').buttonset();

In the above example after buttonset is applied, I want to disable only checkbox with label Two.

Edit

Here is the JSFiddle for the above example. Just by adding attribute disabled does not help.

4

2 回答 2

0

You have to refresh the button widget after disabling the check box:

$("#two").prop("disabled", true).button("refresh");

Updated fiddle here.

于 2012-05-25T13:17:57.933 回答
-1
$("#two").attr("disabled", "disabled");
//OR
$("#two").attr("disabled", true);
于 2012-05-25T12:21:56.433 回答