tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Articles > jQuery > How to check/uncheck a checkbox input or radio button in jQuery

How to check/uncheck a checkbox input or radio button in jQuery

Author: Venkata Sudhakar

The below example shows how to check/uncheck a checkbox input or radio button in jQuery.

01// Check an element with id "item"
02$("#item").prop("checked", true );
03  
04// Uncheck an element with id "item"
05$("#item").prop("checked", false );
06 
07//Example
08function selectAllUsers() {
09    $(".user").each(function() {
10        $(this).prop("checked", true);
11    });
12}
13 
14function unselectAllUsers() {
15    $(".user").each(function() {
16        $(this).prop("checked", false);
17    });
18}

 
  


  
bl  br