Random background images JS
-
Hello,
Is there a simple way to have a random background image on the Home page ?
I know it isn't a lay option but I guess it's something simple in javascript ? (but I don't know js so...)All I know is that it should begin like that :
(id:72 correspond to my landing page)<script> window.laytheme.on("newpageshown", function(layoutObj, type, obj){ if(type == "page" && obj.id == 72){ // Put all of your js, without document ready inside here } }); </script>So basically not much... And add a class in html.
I found a lot of different codes online like those :
http://jsfiddle.net/mrwigster/36cL6/https://fredthewebguy.me/tutorials/load-random-images-page-load-jquery/
but can't make them to work... And I don't know if I should write the paths to the images as a link "http://..." or "/media/img.jpg"
Sorry for my vague message. But it seems a lot of people would to add that to their land page so it would be nice to have an easy solution somewhere.
Thank you very much !
For paid 1-on-1 Lay Theme Coaching, contact Audrey (audrey@cyberslayers.work) or me (info@laytheme.com).
We also code custom websites or bespoke Lay features. Drop me a line at info@laytheme.com or check out my work at arminunruh.com.
Want to support my work? paypal.me/arminunruh
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it