2

using check box as in http://jqueryui.com/button/#checkbox (not the button set)

and want a start over button to uncheck all JQuery check boxes, using Jquery UI the checkboxes are created as inputs so that prop below does not work

 <script>
            $(function() {
                    $( "#startover" ).click(function() {                            
                        $("#mycheck").prop("checked", false);
                    });
            });

Code:

<input type="checkbox" id="mycheck" ><label for="mycheck">clickme</label>
4

2 回答 2

6

Use refresh method to update the visual state of the UI control.

Ref:

Refreshes the visual state of the button. Useful for updating button state after the native element's checked or disabled state is changed programmatically.

Code:

 $(function () {
     $("#mycheck").button();
     $("#startover").click(function () {
         $("#mycheck").prop("checked", false);
         $("#mycheck").button("refresh");
     });
 });

Demo: http://jsfiddle.net/IrvinDominin/TyWcP/

于 2013-09-11T21:13:17.980 回答
1

How about:

$("input:checkbox").prop("checked", false);
于 2013-09-11T21:11:16.447 回答