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?
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?
Call colourFunction()
for each select at load time:
function initialColours() {
colourFunction(document.getElementById('select1'));
colourFunction(document.getElementById('select2'));
};
if (window.addEventListener) {
window.addEventListener('load', initialColours, false);
}
// older IE versions have a non-standard variant, use that
else if (window.attachEvent) {
window.attachEvent('onload', initialColours);
}
on window.load
call that function with the selectbox ids..
try this
window.onload=function(){
colourFunction(document.getElementById('select1'));
colourFunction(document.getElementById('select2'));
};