JSFiddle - React, Tailwind, and code Playground
by dhaval dave
HTML
<samp id="priceid" class="price">25</samp>
<input type="text" name="qty" id="qty" value="2">
JavaScript
var singleprodctprice;
jQuery(document).ready(function() {
var user_price_default = document.getElementById("priceid").innerHTML;
var user_qty_default = jQuery("#qty").val();
if (user_qty_default == "") {
user_qty_default = 1;
}
singleprodctprice = user_price_default / user_qty_default;
jQuery("#qty").change(function() {
var newqty = jQuery("#qty").val();
singleprodctprice_new = singleprodctprice * newqty;
jQuery(".price").html(singleprodctprice_new);
});
});