event delegation

event delegation

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
  <link rel="stylesheet" href="">
  <script>
$( "#container" ).on( "click", "input", function( event ) {
   
    
      var input = e.target;
      var arr = [];
      if
      ( input.is(':checked')=='1')
      {
        arr.push(input.val);
        console.log(input.length);
        } else {
      arr.shift(input.val);
      console.log(input.length);
    }
});
     
  </script>
</head>
<body>
<div id="container">
<p><label><input type="checkbox" id="chk1" value="1" />1</label></p>
<p><label><input type="checkbox" id="chk2" value="3" />2</label></p>
<p><label><input type="checkbox" id="chk3" value="5" />3</label></p>
<p><label><input type="checkbox" id="chk4" value="7"/>4</label></p>
</div>
</body>
</html>