show-notice
hide-notice

Thursday, 15 August 2013

Calculate difference/sum of label values using jQuery


Introduction:

In this post, find jQuery code to calculate difference in label/span values. To fetch the label/span value don't use .val() or .text() method, Instead use .html() method.

Example:
  
 
$(document).ready(function () {
    var nCost = $('#spnCost').html();
    var nSellingPrice = $('#spnSellingPrice').html();
    var nProfit = parseFloat(nSellingPrice) - parseFloat(nCost);
    $('#spnProfit').html(nProfit);
});

SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com