image - Random product thumbnails -


the shop page on website displays "full-length" image of product, , then, on hover, "close-up" image.

i wish randomise this, products, "close-up" displayed on load, , others, "full-length". , have random every page load.

"full-length" images named xxx1.jpg, , "close-up" images xxx2.jpg, e.g.

<li>     <div id="product">         <img class="full-length" src="/image-1.jpg"/>         <img class="close-up" src="/image-2.jpg"/>     </div> </li> 

i guess need random number generator, between 1 , 2, , second image first image not.

any help, sincerely , obliged.

i think can you.java script code is:

function getrandomarbitrary(min, max) {   return math.random() * (max - min) + min; } function onloadsetimage() { document.getelementbyid('product1').src='image-'+getrandomarbitrary(1,5); } 

html (onload can check here):

<body onload="onloadsetimage();"/> <li>   <img id="product1" src=""/> </li> </body> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -