我有一个颜色选择器:
HTML:
<input type="button" id="msg" name="msg" value="msg">
<label for="background-color">Choose a calor for background : </label>
<input id="background-color" type="color" value="#ff0000" onchange="javascript:document.getElementById('chosen-color').value = document.getElementById('background-color').value;"/>
<label for="chosen-color">You have chosen : </label>
<input id="chosen-color" type="text" value="#ff0000"/>
Javascript:
document.getElementById('msg').addEventListener('click', function() {
alert (colorPicker);
}, false);
//Color Picker
var colorPicker = (document.getElementById('chosen-color').value);
当我单击消息框按钮时,消息框仅显示默认值 FF0000,即使它显示不同的值。如何让它显示实际值?