Animated Digital Dice

You can create an animated digital dice easily using the setInterval() method to be used as the timer.
Besides, we use the floor method and the random method to generate random integers from 1 to 6 using the following syntax:

Math.floor( 1 + Math.random() * 6 )

The full script is as follows

<div style="border:4px solid blue; width:8%; text-align:center;padding:0"><h1 id="dice" style="font-size:300%">1</h1></div>
<button onclick="AniDice()">Roll Dice</button>
<button onclick="stopDice()">Stop</button>


function AniDice()

function rolldice()
var ranNum = Math.floor( 1 + Math.random() * 6 );
document.getElementById("dice").innerHTML = ranNum;

function stopDice()

View Animated Digital Dice here.

View Animated Graphical Dice here.