Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  My checkbox: <input type='checkbox' id='check1' />
  My checkbox: <input type='checkbox' id='check2' />
  My button: <input type='button' id='btn' value='Click me'/>
</body>
</html>
 
$(document).ready(function () {
  $('#check1').change(function () {
    if(this.checked) {
      //code to checkbox1 checked.
    } else {
      //code to checkbox1 unchecked.
    }
  });
  $('#check2').change(function () {
    if(this.checked) {
      //code to checkbox2 checked.
    } else {
      //code to checkbox2 unchecked.
    }
  });
  $('#btn').click(function () {
    var checked = $('#check1, #check2').prop('checked', true);
  });
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers