Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Round Off Numbers with Decimal Values Example using JavaScript Math.round Function

Mar 11, 2015
Introduction

Here I will explain how to use
jQuery to round off numbers with decimal values example using JavaScript Math.round function or jQuery round off (roundup or rounddown) number with decimal values using JavaScript Math.round function.


By using Math.round JavaScript function we can round off (roundup or rounddown) numbers with decimal values using jQuery like as shown below


Math.round(10.2345) // returns 10
Math.round(40.789) // returns 41

If you want to check it in complete example you need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Roud off numbers</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
$('#btnClick').click(function () {
$('#lblResult').html(Math.round($('#txtNumber').val()))
});
})
</script>
</head>
<body>
<form id="form1">
<div>
Enter Number: <input type="text" id="txtNumber" value="14245.56345" /><br />
<input type="button" value="Change Number" id="btnClick" />
</div>
Round Off Number:<label id="lblResult" style=" font-weight:bold; font-size:14px"/>
</form>
</body>
</html>
Live Demo

For live demo enter number with decimal value in below textbox and click button to round off numbers


Enter Number:
Round Off Number:

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

vbdgdsbvf

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.