How to calculate discount price in jQuery?

In this article, we will learn about the calculate discount price in jQuery and knew how it works. And I hope you will understand the basic codes behind creating Calculate Discount Price.

First, what we’re doing here, This is the example :

calculate discount price using JQuery in html form
calculate discount price using jQuery result

Calculate discount using jQuery

The basic use of price and discount calculation in any web application is related to different price calculations in the application for user view.

We implement this functionality using jQuery in different web platforms for example offer price and sale price on the E-commerce platform for a better user point of view.

Let’s check how the price discount works:


<!DOCTYPE html>
      <link rel="stylesheet" href="">
      <script src=""></script>
      <script src=""></script>
   <div class="container">
      <div class="row justify-content-center">
         <div class="col-lg-6">
            <div class="main">
               <center><h4 style="color: #BE206B;">Calculate Discount Price in jQuery Example</h4></center>
               <div class="row">
               <div class="col-md-4">
                  <div class="form-group">
                     <label class="bmd-label-floating">Price</label>
                     <input type="text" class="form-control" id="priceBalance">
               <div class="col-md-4">
                  <div class="form-group">
                     <label class="bmd-label-floating">Discount (%)</label>
                     <input type="text" class="form-control" id="priceDiscount">
               <div class="col-md-4">
                  <div class="form-group">
                     <label class="bmd-label-floating">Price After Discount</label>
                     <input type="text" class="form-control" id="priceResult" readonly>
   $(document).on("change keyup blur", "#priceDiscount", function() {
     var main = $('#priceBalance').val();
     var disc = $('#priceDiscount').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;

In this article, we learned “How to calculate the discount price in jQuery”, I hope this article will help you with your web application Project.

Read also-: Strong password jQuery validation.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress.

Scroll to Top