Load random CSS on page refresh
问题 I was wondering whats the best way to call a random css file on page refresh with Javascript? Many thanks 回答1: var link = []; link[0] = "http://site.com/css/style1.css"; link[1] = "http://site.com/css/style2.css"; link[2] = "http://site.com/css/style3.css"; $(function() { var style = link[Math.floor(Math.random() * link.length )]; $('<link />',{ rel :'stylesheet', type:'text/css', href: style }).appendTo('head'); }); Edit : Thank you Basil Siddiqui! var link = []; link[0] = "http://site.com