input type color
<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的更多相关文章
- html5 input type="color"边框伪类效果
html5为input提供了新的类型:color <input type="color" value="#999" id="color" ...
- 给<input type="color">设置默认值
参考:https://stackoverflow.com/questions/14943074/html5-input-colors-default-color?utm_medium=organic& ...
- [HTML5] 颜色选择器的操作[input type='color'....]
一.点击事件和获取颜色值 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- input type=color 设置颜色
在设置背景色的时候,使用html5 type=color 标签,但是初始值一直都是黑色的,背景如果没有设置的时候,应该是白色,比如文本图元,所以需要设置一个初始的颜色值, 注意: value不实用,怎 ...
- input type类型和input表单属性
一.input type类型 1.Input 类型 - email 在提交表单时,会自动验证 email 域的值. E-mail: <input type="email" n ...
- 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"> < ...
- 输入类型<input type="number"> / input标签的输入限制
输入限制 属性 描述 disabled 规定输入字段应该被禁用. max 规定输入字段的最大值. maxlength 规定输入字段的最大字符数. min 规定输入字段的最小值. pattern 规定通 ...
- input type="datetime-local" 时placeholder不显示
一个坑,input的type="datetime-local" 时,电脑上会显示提示,如图 <input type="datetime-local" na ...
- 上传文件 隐藏input type="file",用text显示
<div> <span>上传文件:</span> <input type="file" id="upload_file" ...
随机推荐
- Apache Commons FileUpload实现文件上传
一.Apache Commons-FileUpload简介 Apache Commons是一个专注于可重用Java组件的所有方面的 Apache 项目. Apache Commons项目由三个部分组成 ...
- mysql学习之基础篇07
视图:view 在查询的时候我们经常把查询到的结果当成一张临时表来看,其实view就可以看成一张虚拟表,是表通过某种运算得到的投影 那么如何创建视图?创建视图需要指定视图的列名和列类型吗? 答:不用, ...
- 13.5. zipfile — Work with ZIP archives
13.5. zipfile — Work with ZIP archives Source code: Lib/zipfile.py The ZIP file format is a common a ...
- 191010 python3分解质因数
# 题目:将一个正整数分解质因数.例如:输入90,打印出90=2*3*3*5.# 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:# (1)如果这个质数恰等于n,则说明分解 ...
- 用js刷剑指offer(丑数)
题目描述 把只包含质因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含质因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 思路 ...
- rocketmq那些事儿之集群环境搭建
上一篇入门基础部分对rocketmq进行了一个基础知识的讲解说明,在正式使用前我们需要进行环境的搭建,今天就来说一说rockeketmq分布式集群环境的搭建 前言 之前已经介绍了rocketmq的入门 ...
- Sql中的left函数、right函数
DB2中left()函数和right()函数对应oracle中的substr()函数 DB2 LEFT.RIGHT函数 语法:LEFT(ARG,LENGTH).RIGHT(ARG,LENGTH) LE ...
- stm32进入HardFault_Handler的定位方法
写程序偶尔会遇到程序死机的现象.这个时候,就需要debug来定位. 通常情况下,程序会进入HardFault_Handler的死循环(针对stm32系列),我遇到过两次. 第一次是使用数组之前,数组的 ...
- PostgreSQL 查看表、索引等创建时间
select s.oid,s.relname,t.stausename,t.stasubtype from pg_class s,pg_stat_last_operation t where s.re ...
- Apache Kylin在4399大数据平台的应用
来自:AI前线(微信号:ai-front),作者:林兴财,编辑:Natalie作者介绍:林兴财,毕业于厦门大学计算机科学与技术专业.有多年的嵌入式开发.系统运维经验,现就职于四三九九网络股份有限公司, ...