JSFiddle - React, Tailwind, and code Playground
by sarathsprakash
HTML
<table border="1">
<tr>
<th>Select</th>
<th>Cell phone</th>
<th>Rating</th>
<th>Location</th>
</tr>
<tr>
<td align="center">
<input type="checkbox" class="case" name="case[]" value="1" />
</td>
<td>BlackBerry Bold 9650</td>
<td>2/5</td>
<td>UK</td>
</tr>
<tr>
<td align="center">
<input type="checkbox" class="case" name="case[]" value="2" />
</td>
<td>Samsung Galaxy</td>
<td>3.5/5</td>
<td>US</td>
</tr>
<tr>
<td align="center">
<input type="checkbox" class="case" name="case[]" value="3" />
</td>
<td>Droid X</td>
<td>4.5/5</td>
<td>REB</td>
</tr>
</table>
JavaScript
var values = {};
function myfunc(ele) {
$.each($("input[name='case[]']:checked"),
function (i, e) {
values[i] = {};
$.each($(this).closest("td").siblings("td"), function (j, k) {
values[i][j] = $(this).text();
});
});
console.log(values);
}
$(document).ready(function () {
$("input.case").click(myfunc);
});