代码示例:(标识:htmldom_color_create)
<!DOCTYPE html>
<html>
<body>

<p>单击按钮可创建颜色选择器。</p>

<button onclick="myFunction()">试一试</button>

<script>
function myFunction() {
  var x = document.createElement("INPUT");
  x.setAttribute("type", "color");
  document.body.appendChild(x);
}
</script>

</body>
</html>
运行结果: