我需要帮助使这个 Javascript 更改 div 之间“我爱乔治布朗”的颜色,我得到它来更改字体颜色,当我设置背景颜色的更改时,唯一有效的颜色是相同的颜色字体颜色。请帮忙,我需要用纯javascript来做这件事。
http://jsfiddle.net/jonrobert/tuEe6/
<script>
function changeColor()
{
var newColor = document.getElementById('colorPicker').value;
document.getElementById('colorMsg').style.color = newColor;
}
function changeBack()
{
var back = document.getElementById('colorPicker').value;
document.getElementById('colorMsg').style.background = back ;
}
</script>
<div id="colorMsg" style="font-size:50px; text-align:center; margin-bottom:200px;width:150px;height:100px;padding:5px;">I LOVE GEORGE BROWN</div>
<h2>Choose Font Color</h2>
<select id="colorPicker" onchange="JavaScript:changeColor()">
<option value="transparent">None</option>
<option value="yellow">Yellow</option>
<option value="salmon">Salmon</option>
<option value="lightblue">Light Blue</option>
<option value="limegreen">Lime Green</option>
<option value="cyan">Cyan</option>
<option value="violet">Violet</option>
<option value="red">Red</option>
</select>
<div id="colorMsg"></div>
<h2>Choose Background Color:</h2>
<select id="colorPicker" onchange="JavaScript:changeBack()">
<option value="transparent">None</option>
<option value="yellow">Yellow</option>
<option value="salmon">Salmon</option>
<option value="lightblue">Light Blue</option>
<option value="limegreen">Lime Green</option>
<option value="cyan">Cyan</option>
<option value="violet">Violet</option>
<option value="red">Red</option>
</select>
</body>
</html>