# Other Languages > jQuery >  separatly treat checkbox in two different html table

## ERUM

suppose if i have two html table table1 and table2
and each have rows with css class "case" .. each html have header with selectall checkboxes .so if i check selectall checkbox of table1 and i want to check all rows checkboxes of table1 with class css .and if second html table i.e table2 selectall checkbox select ..it should select rows of table2 with css "case"..how do this ????

please not down that two html table with different name and header checkbox name is also different but same css of checkboxes in data rows of html table

----------


## sapator

If you have 2 tables with different ID's then getting the wanted table ID will pretty much do everything you need for the specific table.
I'm guessing a loop that checks all in checkboxes after. Not ready to give full answer and no VS here but a for each element in tableX , if elements is checkbox then, if not checked then check.
I think would be a basic task if you google it.

----------


## Sherin

Hello,@ERUM  
Please try this code, To separatly treat checkbox in two different html table


```
$('#select_all1').bind('click', function() {
  var checkedState = this.checked;
  $('#table1 :checkbox').each(function() {
      this.checked = checkedState;
  });
});

$('#select_all2').bind('click', function() {
  var checkedState = this.checked;
  $('#table2 :checkbox').each(function() {
      this.checked = checkedState;
  });
});
```



```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" id="select_all1"></input>
<table id="table1">
  <tr>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
  </tr>
  <tr>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
  </tr>
</table>

<input type="checkbox" id="select_all2"></input>
<table id="table2">
  <tr>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
  </tr>
  <tr>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
    <td>
      <input type="checkbox" />
    </td>
  </tr>
</table>
```

I hope this code will be useful to you.
Thank you.

----------

