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_email_data = jQuery("#priceid").val();
  var user_price_default = document.getElementById("priceid").innerHTML;
  //var user_price_default = jQuery("#priceid").val(); 	
  alert(user_price_default);
  var user_qty_default = jQuery("#qty").val();
  alert(user_qty_default);
  if (user_qty_default == "") {
    user_qty_default = 1;
  }
  singleprodctprice = user_price_default / user_qty_default;
  alert(singleprodctprice);
  jQuery("#qty").change(function() {
    var newqty = jQuery("#qty").val();
    alert(singleprodctprice);
    alert(newqty);
    singleprodctprice_new = singleprodctprice * newqty;
    alert(singleprodctprice_new);
    jQuery(".price").html(singleprodctprice_new);
  });
});