Bootstrap Table
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<div class="container-fluid">
<div class="table-responsive">
<table id="tabela_amostras" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
<th class="all" align="center"><h3 class="panel-title" align="center">Amostra</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Nota</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Pele</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Azedo</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Gordura</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Alcalino</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Ácido</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Anti Esp.</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Doce</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Ração</h3></th>
<th class="all" align="center"><h3 class="panel-title" align="center">Sabão</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td class="all" align="center">150</td>
<td class="all" align="center">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default btn-number" data-type="minus" data-field="num">
<span class="glyphicon glyphicon-minus"></span>
</button>
</span>
<input class="form-control...
JavaScript
$('.btn-number').click(function(e){
e.preventDefault();
var fieldName = $(this).attr('data-field');
var type = $(this).attr('data-type');
var input = $("input[name='"+fieldName+"']");
var currentVal = parseInt(input.val());
if (!isNaN(currentVal)) {
if(type == 'minus') {
var minValue = parseInt(input.attr('min'));
if(!minValue) minValue = 1;
if(currentVal > minValue) {
input.val(currentVal - 1).change();
}
if(parseInt(input.val()) == minValue) {
$(this).attr('disabled', true);
}
} else if(type == 'plus') {
var maxValue = parseInt(input.attr('max'));
if(!maxValue) maxValue = 9999999999999;
if(currentVal < maxValue) {
input.val(currentVal + 1).change();
}
if(parseInt(input.val()) == maxValue) {
$(this).attr('disabled', true);
}
}
} else {
input.val(0);
}
});
$('.input-number').focusin(function(){
$(this).data('oldValue', $(this).val());
});
$('.input-number').change(function() {
var minValue = parseInt($(this).attr('min'));
var maxValue = parseInt($(this).attr('max'));
if(!minValue) minValue = 1;
if(!maxValue) maxValue = 4;
var valueCurrent = parseInt($(this).val());
var name = $(this).attr('name');
if(valueCurrent >= minValue) {
$(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
} else {
alert('Sorry, the minimum value was reached');
$(this).val($(this).data('oldValue'));
}
if(valueCurrent <= maxValue) {
...