round number with js

Round a number to two decimal places.


var rounded = Math.round(num * 100) / 100;



demo code

<p><input type='text' id='rval' value='16.67894562346'></p>

<p><pre id='rounded_result'>Result...</pre></p>

	function round_val() {
		var val = $("#rval").val();
		var rounded = Math.round(val * 100) / 100;

<p><button class='btn btn-dark' onclick='round_val();'>Round It</button></p>

Other Items in js
Related Search Terms
Page Views

This page has been viewed 386 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
1. Show your work to the world instead of keeping in your head💆. 2. Do the work consistently👌 3. Respect your work🥰 4. Don't postpone your work 5. Make mistakes 🔥🔥🔥