JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tbody>
<tr>
<td><input id=1 onmouseover='check(1)' type="checkbox"></td>
<td><input id=2 onmouseover='check(2)' type="checkbox"></td>
<td><input id=3 onmouseover='check(3)' type="checkbox"></td>
</tr>
<tr>
<td><input id=4 onmouseover='check(4)' type="checkbox"></td>
<td><input id=5 onmouseover='check(5)' type="checkbox"></td>
<td><input id=6 onmouseover='check(6)' type="checkbox"></td>
</tr>
<tr>
<td><input id=7 onmouseover='check(7)' type="checkbox"></td>
<td><input id=8 onmouseover='check(8)' type="checkbox"></td>
<td><input id=9 onmouseover='check(9)' type="checkbox"></td>
</tr>
</tbody>
</table>
<script>
function check(id)
{
if(mouseDown)
{
console.log(mouseDown);
console.log(document.getElementById(id).checked);
document.getElementById(id).checked = 1-document.getElementById(id).checked;
// document.getElementById(id).checked = true;
// ^ If you only want to turn them on, use this.
}
}
var mouseDown = 0;
document.body.onmousedown = function()
{
++mouseDown;
}
document.body.onmouseup = function()
{
--mouseDown;
}
// Credit to http://stackoverflow.com/questions/322378/javascript-check-if-mouse-button-down
</script>