I have an array that holds some checkbox id numbers that are added when a user clicks on some checkboxes in a table. I want to disable a button if the array is empty and enable it when it has some items.
var ids = [];
$('#Table tbody').on('click', '.checkbox', function () {
var idx = $.inArray($(this).attr("id"), ids);
if (idx == -1) {
ids.push($(this).attr("id"));
} else {
ids.splice(idx, 1);
}
});
What's the best way to monitor the array and check whether an element has been added to the id array or brought back down to 0 to enable/disable the button?
<input class="btn disabled" type="submit" name="submit" id="btnsubmit" value="Submitselected"/>