title: How to get checked items from checklistbox MVC Razor
body: <p>In a div, I have some <code>CheckBoxList</code> using <code>CheckBoxListFor</code> in <code>MVC Razor</code>. I'd like when I push a button to get all the values of all check boxes checked. How to do this?</p>
  
  <pre><code> &lt;div class="col-md-4"&gt;
                  &lt;label for="" class="control-label"&gt;
                      Branch&lt;/label&gt;&lt;br /&gt;
                  @Html.CheckBoxListFor(m =&gt; m.SearchBranchSeq,MultiSelectList)Model.SearchBranches, new {@id="SearchBranches", @style = "overflow: auto; height: 100px; width: 250px; border: 1px solid #cccccc;" })
  
              &lt;/div&gt;
  </code></pre>
  
  <p>And I tried like the following,</p>
  
  <pre><code>var SearchBranchSeq = [];
      $('input:checkbox').click(function () {
        if ($(this).is(':checked')) {
              SearchBranchSeq.push($(this).val());
        }
        else {
              var x = SearchBranchSeq.valueOf($(this).val());
              SearchBranchSeq.splice(x, 1);
  
        }
    });
  </code></pre>
  
  <p>It is working, but I cannot remove the value in <code>SearchBranchSeq</code> when I uncheck a check box from the <code>CheckBoxList</code>. Can anyone help me to find the solution?</p>