I am trying to make a multiplication between quantity and price, to get your total, however I get the following error when doing it: TypeError: $(...).nextElementSibling is not a function
, I do not know in what way I could modify it in such a way that it is acceptable, I share my code:
form
<form>
<input type="text" id="quantity">
<input type="text" id="price">
<input type="text" class="result">
</form>
script
<script>
$('#quantity, #price').keyup(function(){
var cant = parseFloat(this.nextElementSibling('#quantity').val()) || 0;
var price = parseFloat(this.nextElementSibling('#price').val()) || 0;
var result = cant * price
this.nextElementSibling('.result').val(result);
})
</script>