Simple Example of setting Random Switching of background images in js, and js background image instance
Example:
<script> var imgs =["http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_2.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_default.png", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_3.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_1.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_4.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_5.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_6.jpg", "http://images.cnblogs.com/cnblogs_com/xiaobo-Linux/1112236/o_default-2.jpg", ]; var index=Math.floor(Math.random()*8);var img = imgs[index]; function time(){ document.body.style.backgroundImage="url("+img+")"; } document.body.onload = function(){ time();}</script>
The simple example of setting a Random Switching background image in the above section is all the content shared by Alibaba Cloud. I hope you can give us a reference and support for the customer's house.