<input type="color">

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color

JavaScript

First, there's some setup. Here we establish some variables, setting up a variable that contains the color we'll set the color well to when we first load up, and then setting up a load handler to do the main startup work once the page is fully loaded.

var colorWell;
var defaultColor = "#0000ff"; window.addEventListener("load", startup, false);

Initialization

Once the page is loaded, our load event handler, startup(), is called:

function startup() {
colorWell = document.querySelector("#colorWell");
colorWell.value = defaultColor;
colorWell.addEventListener("input", updateFirst, false);
colorWell.addEventListener("change", updateAll, false);
colorWell.select();
}

This gets a reference to the color <input> element in a variable called colorWell, then sets the color input's value to the value in defaultColor. Then the color input's input event is set up to call our updateFirst() function, and the change event is set to call updateAll(). These are both seen below.

Finally, we call select() to select the text content of the color input if the control is implemented as a text field (this has no effect if a color picker interface is provided instead).

使用JQuery

 /*color*/
$('[type=color]').on('change', function () {
var block = $(this).parents('.blockquote');
block.find('.br-ccc').css('background-color', $(this).val());
block.find('[type=text]').val($(this).val());
});
 $('#nav-page-styling [name]').each(function () {
var value = page.model.Page[$(this).attr('name')];
$(this).val(value);
$(this).parents('.blockquote').find('.br-ccc').css('background-color', $(this).val());
});

input type color的更多相关文章

  1. html5 input type="color"边框伪类效果

    html5为input提供了新的类型:color <input type="color" value="#999" id="color" ...

  2. 给<input type="color">设置默认值

    参考:https://stackoverflow.com/questions/14943074/html5-input-colors-default-color?utm_medium=organic& ...

  3. [HTML5] 颜色选择器的操作[input type='color'....]

    一.点击事件和获取颜色值 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  4. input type=color 设置颜色

    在设置背景色的时候,使用html5 type=color 标签,但是初始值一直都是黑色的,背景如果没有设置的时候,应该是白色,比如文本图元,所以需要设置一个初始的颜色值, 注意: value不实用,怎 ...

  5. input type类型和input表单属性

    一.input type类型 1.Input 类型 - email 在提交表单时,会自动验证 email 域的值. E-mail: <input type="email" n ...

  6. Html5学习3(拖放、Video(视频)、Input类型(color、datetime、email、month 、number 、range 、search、Tel、time、url、week ))

    1.Html拖放 <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> < ...

  7. 输入类型<input type="number"> / input标签的输入限制

    输入限制 属性 描述 disabled 规定输入字段应该被禁用. max 规定输入字段的最大值. maxlength 规定输入字段的最大字符数. min 规定输入字段的最小值. pattern 规定通 ...

  8. input type="datetime-local" 时placeholder不显示

    一个坑,input的type="datetime-local" 时,电脑上会显示提示,如图 <input type="datetime-local" na ...

  9. 上传文件 隐藏input type="file",用text显示

    <div> <span>上传文件:</span> <input type="file" id="upload_file" ...

随机推荐

  1. .NET CORE 技术债

    技术债:OCELOT 网关/熔断/降级/限流CONSUL 服务注册/发现CAP 分布式事件总线SKYWALKING 微服务监控

  2. java web编程 servlet读取配置文件参数

    新建一个servlet. 然后在web.xml文件里面自动帮助你创建好了<servlet-name><servlet-class><servlet-mapping> ...

  3. jenkins节点添加

    https://blog.csdn.net/bbwangj/article/details/81203381

  4. MySQL Binlog--基于ROW模式的binlog event大小限制

    参数binlog-row-event-max-size:Specify the maximum size of a row-based binary log event, in bytes. Rows ...

  5. ubuntu下关于profile和bashrc中环境变量的理解(转)

    ubuntu下关于profile和bashrc中环境变量的理解(转)   (0) 写在前面 有些名词可能需要解释一下.(也可以先不看这一节,在后面看到有疑惑再上来看相关解释) $PS1和交互式运行(r ...

  6. Scrum会议博客以及测试报告

    3组Alpha冲刺阶段博客目录 一.Scrum Meeting1. 第六周会议记录(链接地址:https://www.cnblogs.com/Cherrison-Time/articles/11788 ...

  7. netty websocket

    1 全局保存websocket的通道  NettyConfig.java public class NettyConfig { public static ChannelGroup group = n ...

  8. 51nod 1305 Pairwise Sum and Divide

    有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整:   fun(A)     sum = 0     for i = 1 to A.length         for j = ...

  9. MongoDB与Python的交互

    驱动模块 pymongo是python里常用的操作MongoDB的驱动模块 可用pip下载安装 pip install pymongo 创建连接 MongoClient是MongoDB的客户端代理对象 ...

  10. Python凯撒密码和括号匹配

    1.凯撒密码: 除了特殊字符不转化,其余的按照规定经行转译,以下以a~z和A~Z的字符都进行转译. plaincode = input("")print(len(plaincode ...