JSFiddle - React, Tailwind, and code Playground
by Brock Angelo
HTML
<table id="table">
<thead>
<tr>
<th>File</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>First</td>
<td>1</td>
</tr>
<tr>
<td>Second</td>
<td>2</td>
</tr>
</tbody>
</table>
<hr />
<button type="button" id="analyze" disabled=true>Analyze</button>
CSS
.selected {
background: lime;
}
table {
width: 200px;
}
JavaScript
var checkButton = function() {
if ($('tr.selected').length > 0) {
$('#analyze').prop('disabled', false);
} else {
$('#analyze').prop('disabled', true);
}
}
$('#table tbody').on( 'click', 'tr', function () {
$(this).toggleClass('selected');
checkButton();
});