Bar*_*man 6 html javascript browser color-picker
有没有人知道javascript只能打开浏览器标准的colorpicker,而不使用html字段?所以我想要一个javascript什么完全相同的点击html输入颜色字段.巴特
您将不得不使用输入字段,您可以将其隐藏在页面之外.这里的问题是,颜色对话框需要在浏览器中单击才能打开颜色对话框.如果你只是调用click()它将无法工作
document.getElementById("xxx").addEventListener("click", function() {
document.getElementById("c").focus();
document.getElementById("c").value = "#FFCC00";
document.getElementById("c").click();
});Run Code Online (Sandbox Code Playgroud)
.hidden {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}Run Code Online (Sandbox Code Playgroud)
<input type="color" id="c" tabindex=-1 class="hidden">
<input type="button" id="xxx" value="Click Me!">Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11315 次 |
| 最近记录: |