-2
I have a problem after pressing a button on my page, using Jquery.
After the click, a function should be done and then the result would be displayed on the screen, but I noticed that after clicking the button, the function is executed and the result shown however in fraction of seconds, and the page is reloaded then.
follows the HTML and JS referring to that part :
<div class="list-group" id='allResultBasal'>
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start active" id='basalHomem'>
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Homem</h5>
<small><span id='subClassM'>Clique para entender</span></small>
</div>
<p class="mb-1">
<br>
Seu Consumo Calórico Basal é:<br>
<small class="text-muted">Donec id elit non mi porta.</small>
<span id='resultHomem'> </span>
</p>
<small></small>
</a>
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start" id='basalMulher'>
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Mulher</h5>
<small class="text-muted"><span id='subClassM'>Clique para entender</span></small>
</div>
<p class="mb-1"><br>Seu Consumo Calórico Basal é:<br></p>
<small class="text-muted">Donec id elit non mi porta.</small>
</a>
</div>
the JS :
$("#botaoBasal").click(function(){
var pesoB = $("#inputPassword3").val();
var alturaB = $('#inputPassword2').val();
var idadeB = $('#inputEmail3').val();
var generoB = $("input[name='gridRadios']:checked").val();
var basal ='nothing';
if (generoB == 'h'){
var basal = 66.5 + (13.75 * pesoB) + (5 * alturaB ) - (6.8 * idadeB);
//66,5 + (13,75 x Peso) + (5,0 x Altura em cm) – (6,8 x Idade).
$('#basalHomem').css('visibility', 'visible');
//$('#resultHomem').text(basal +'kcal/dia');
}else if (generoB == 'm'){
var basal = 665.1 + (9.56 * pesoB) + (1.8 * alturaB) - (4.7 * idadeB);
// 665,1 + (9,56 x Peso) + (1,8 x Altura em cm) – (4,7 x Idade).
$('#basalMulher').css('visibility', 'visible');
//$('#resultMulher').text(basal +'kcal/dia');
}
console.log(basal);
});