Generate Random Fractions with JavaScript

generate a random fraction and add it to result when clicking a button
function randomFraction() {
  var result_html = document.getElementById("result");
  var random_number = Math.random();
  result_html.innerHTML = random_number;
  return random_number;


<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='randomFraction();' class='btn btn-primary'>randomFraction</button>



Other Items in js
Page Views

This page has been viewed 284 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
Don't look to be the next Facebook, try to solve a real problem instead.