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>
Latest posts
- bootstrap popover | bootstrap popover hide on click | bootstrap popover hide on document.click
- Avoid console errors in browsers that lack a console | HTML5 boilerplate
- getting started with Sublime editor | how to install zen coding | zen coding for sublime editor
- getting started with backbone | Models in Backbone
- How to delete a model in backbone






