Step 1:Create index.html file and implement below code.
<label>Price</label> <input class="form-control" type="number" id="cBalance" value=""><br> <br><br> <label>precentage</label> <input class="form-control" type="number" id="chDiscount"> <br><br> <label>Result</label> <input class="form-control" type="number" id="result">
Step 2:Implement jQuery to copy textarea data.
<script> $(document).on("change keyup blur", "#chDiscount", function() { var main = $('#cBalance').val(); var disc = $('#chDiscount').val(); var dec = (disc / 100).toFixed(2); //its convert 10 into 0.10 var mult = main * dec; // gives the value for subtract from main value var discont = main - mult; $('#result').val(discont); }); </script>
Complete Code For Calculating Discount Using Jquery
<!DOCTYPE html> <html> <head> <title>How Can I Calculate Discount Using Jquery With Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <style> body { background: black; } </style> <body> <div class="container"> <br><br><br> <div class="text-center"> <h1 id="color" style="color: White;">Calculate Discount Using Jquery</h1> </div> <br> <div class="col-md-2"></div> <div class="col-md-8"> <div class="well"> <label>Price</label> <input class="form-control" type="number" id="cBalance" value=""><br> <br><br> <label>precentage</label> <input class="form-control" type="number" id="chDiscount"> <br><br> <label>Result</label> <input class="form-control" type="number" id="result"> </div> </div> <div class="col-md-2"></div> </div> </body> </html> <script> $(document).on("change keyup blur", "#chDiscount", function() { var main = $('#cBalance').val(); var disc = $('#chDiscount').val(); var dec = (disc / 100).toFixed(2); //its convert 10 into 0.10 var mult = main * dec; // gives the value for subtract from main value var discont = main - mult; $('#result').val(discont); }); </script>