jQuery unset all checkboxes and radio buttons

This code snippet will clear all checkboxes and radio buttons in a form using a click event on a clear button.

HTML

<form id="my-form">
    <!--- form fields --->
    <input type="button" id="clear-form" value="Clear" />
</form>

JQuery

    $('#clear-form').on('click', function()
    { 
        $('#my-form').find('input:radio, input:checkbox').prop('checked', false);
    });

For clearing or resetting all form elements check out this post.

Sign Up
comments powered by Disqus
Sign Up

Popular Tags

350x250

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.