JS设置颜色选择器值
问题描述:
我想更改颜色选择器值。 像这样 $('#headcolor')。val('#e2e2e2');JS设置颜色选择器值
headcolor是
<input id="headcolor" type="color" />
我需要帮助:(对不起我的英语
答
在这里,我已经展示了改变文本的颜色使用拾色器
<html>
<body>
<input id="headcolor" type="color" onchange="func()"/>
<p id="temp">Click the button to change the value of the text field.</p>
<script>
function func() {
document.getElementById("temp").style.color = document.getElementById("headcolor").value;
}
</script>
</body>
</html>
工作JsFiddle
答
你可以只用JavaScript的这样做:document.getElementById("headcolor").value="#e2e2e2";
参考:http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_color_value
希望它有帮助!