The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Random hover on page load Reply To: Random hover on page load


Just rename your image files to 1.jpg, 2.jpg, 3.jpg, etc. and use the reduced img markup and CSS provided in your php web page. The paragraphs in the top 2 lines are just a description and standalone demo to explain/show what’s going on, and are not necessary for the functionality of the sample.

The script is randomly writing a number from 1-5 into the markup as the img src filename. If you view the source of the page or inspect it in the dev console, you’ll be able to see what’s happening.