round off decimal 2 places using javascript

<p id=”demo”>Click the button to display the formatted number.</p>
<button onclick=”myFunction()”>Try it</button>

<script type=”text/javascript”>// <![CDATA[
function myFunction()
var x = 4.99999;
x = Math.floor(x * 100) / 100;
alert(x.toFixed(2)); // alerts 4.99
// ]]></script>



I Am suresh(suresh kumar )a Web developer,Freelancer,webdesigner,UI developer from bangalore. Got 6+ yrs of IT experience . I specialize in standards-based XHTML, CSS and JavaScript web development. Each site I develop is built to be search engine friendly (SEO), using the latest development principles and techniques.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *