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>
3
  • What do you mean "all checkboxes except input"? Commented Sep 11, 2013 at 21:06
  • edited to explain better Commented Sep 11, 2013 at 21:08
  • The prop is supposed to work even on check boxes that were dynamically added to the DOM. You should consider providing us with a jsfiddle.net showing your relevant problem. Commented Sep 11, 2013 at 21:11

2 Answers 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/

Sign up to request clarification or add additional context in comments.

1 Comment

Total life saver, Thanks for showing the part about refresh. I was letting jquery change a checkbox to button styling and couldnt for the life of me figure out how to make the button reflect the sate of the checkbox. This fixed the issue nicely.
1

How about:

$("input:checkbox").prop("checked", false);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.