Generate random number and place it inside image URL - Javascript Math

Javascript examples for Math:random

Description

Generate random number and place it inside image URL

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width"> 
   </head> 
   <body> 
      <img id="the-image" src="https://example.com/number="> 
      <script>
var image = document.querySelector('#the-image');
var number = Math.random()*10000000000000000;
image.src += number;//w w  w  .ja va  2  s  . c  o  m
console.log(image.src)

      </script>  
   </body>
</html>

Related Tutorials