如何禁用jQuery-UI buttonset的一个按钮?

Eri*_*air 2 javascript jquery jquery-ui jquery-ui-button jqueryi-ui-buttonset

这里的例子:

http://jsfiddle.net/UVHtu/19/

我需要填补空白:

HTML:

<div id="options">
    <input type="radio" id="op_a" name="op" value="a" />
    <label for="op_a">Option A</label>
    <input type="radio" id="op_b" name="op" value="b" />
    <label for="op_b">Option B</label>
    <input type="radio" id="op_c" name="op" value="c" />
    <label for="op_c">Option C</label>
</div>
<input type="button" id="disable_button" value="Disable Option B" />
?
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

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

$("#disable_button").click(function(){
    // What goes here to disable option B?
});
Run Code Online (Sandbox Code Playgroud)

Bif*_*iff 10

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

$("#disable_button").click(function(){
    // What goes here?
    $('#op_b').attr("disabled", "disabled");
    $("#options").buttonset("refresh");
});
Run Code Online (Sandbox Code Playgroud)

  • 在那种情况下,我建议使用`prop`而不是`attr`.http://stackoverflow.com/questions/5874652/prop-vs-attr (2认同)