I am doing a calculator with jQuery and Bootstrap but it is not adding me well, in this case only jQuery content that is where the problem is. The rest works perfectly, but in the calculations is not going well, I have the following code:
var total = 0;
$(document).ready(function() {
$("#boton_igual").click(function() {
//if ($("#resultado").val().trim().length != 0) {
$("#resultado").val(total);
//}
});
});
$(document).ready(function() {
$("#boton_sumar").click(function() {
if ($("#resultado").val().trim().length > 0) {
total += parseInt($("#resultado").val());
$("#resultado").val('');
}
});
});
$(document).ready(function() {
$("#boton_borrar").click(function() {
$("#resultado").val('');
total = '';
});
});
First I'm trying the sum but I do not know why the sum is wrong.