Apply select bg color on load?
问题 Please look at the following link to see my code in action: http://codepen.io/DigitalSquid/pen/mAkuC How can I make the bg color appear on page load? 回答1: on window.load call that function with the selectbox ids.. try this window.onload=function(){ colourFunction(document.getElementById('select1')); colourFunction(document.getElementById('select2')); }; 回答2: Call colourFunction() for each select at load time: function initialColours() { colourFunction(document.getElementById('select1'));