I'm trying to take value from input field, do simple calculation and display the answer to the form element.
<script type="text/javascript">
$(document).ready(function () {
$("#number_ticket").change(function () {
var adult = parseInt($(this).val()) * parseInt($('#price_adults').textContent);
$('#total_price_adults').text(adult);
});
});
</script>
Here's my HTML
<div class="st_adults_children">
<span class="label">Adults</span>
<div class="input-number-ticket">
<input type="number" name="number_ticket" value="1" min="1"
max="10" placeholder="Number ticket of Adults"
id="number_ticket">
</div>
×
$<span class="price_adults" id="price_adults">{{$single->price}}</span>
=
<span class="total_price_adults" id="total_price_adults">$93</span>
</div>
I've tried removing parseInt() from $(this).val(), since the value is already integer. I couldn't work out what's wrong here.