Sna*_*yes 6 javascript jquery jquery-ui
我有3个单选按钮
<div id="test">
<input type="radio" id="time1" name="radio" value="1" /><label for="time1">Test 1</label>
<input type="radio" id="time2" name="radio" value="2" /><label for="time2">Test 2</label>
<input type="radio" id="time3" name="radio" value="3" /><label for="time3">Test 3</label>
</div>
Run Code Online (Sandbox Code Playgroud)
在jquery
$("#test").buttonset();
Run Code Online (Sandbox Code Playgroud)
在那之后,我想禁用它们(当然,禁用被放在一个if声明中)
$("#test input").attr("disabled", true); //or
$("#test input").prop("disabled", true);
Run Code Online (Sandbox Code Playgroud)
但它不起作用,按钮仍然启用.
gdo*_*ica 11
您正在使用jQuery-UI,在更改单选按钮后buttonset,它们不再影响UserInterface,因为它包含:
<div id="test" class="ui-buttonset">
<input type="radio" id="time1" name="radio" value="1" class="ui-helper-hidden-accessible"><label for="time1" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" role="button" aria-disabled="false"><span class="ui-button-text">Test 1</span></label>
<input type="radio" id="time2" name="radio" value="2" class="ui-helper-hidden-accessible"><label for="time2" aria-pressed="false" class="ui-button ui-widget ui-state-default ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Test 2</span></label>
<input type="radio" id="time3" name="radio" value="3" class="ui-helper-hidden-accessible"><label for="time3" aria-pressed="true" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right ui-state-active" role="button" aria-disabled="false"><span class="ui-button-text">Test 3</span></label>
</div>
Run Code Online (Sandbox Code Playgroud)
所以你需要jQuery UI功能来禁用"按钮"(这是spans!)
$("#test input").button("disable")
Run Code Online (Sandbox Code Playgroud)
$("#test > input:radio").button({disabled:true});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6800 次 |
| 最近记录: |