Sunday, January 11, 2015

JavaScript - Division using Math.Ceil function


Here I will explain how to number division in JavaScript or jQuery using Math.ceil() method. Math.ceil() method will rounds number upwards to next nearest integer.

Declaration of Math.ceil() method
Generally we will use Math.ceil() method like as shown below

var result = Math.ceil(45 / 4);
alert(result + ", " + div);

The complete Example using the JavaScritp Math.ceil function.

<html xmlns="">
<title>Get Whole Number Division in Javascript</title>
<script type="text/javascript">
function Getdivision() {
var result = Math.ceil(45 / 4);
alert("Result: " + result);
<form id="form1">
<input type="button" value="Click to Get Division Value" onclick="Getdivision()" />

No comments:

Post a Comment