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" ...
随机推荐
- git 分支查看与切换
git 分支查看与切换 # 1.查看所有分支 > git branch -a # 2.查看当前使用分支(结果列表中前面标*号的表示当前使用分支) > git branch # 3.切换分支 ...
- Java8新特性Function、BiFunction使用
闲话不多说,直接看代码,注释都写的很清楚了. package com; import java.util.function.BiFunction; import java.util.function. ...
- 【Flask】 python学习第一章 - 2.0 视图方式和返回值
路由参数与请求方式制定 ALT+回车 pycharm 快速导包 demo3 指定访问地址 与请求方式 # 给路由传入参数 使用尖括号 ,视图函数需要接收参数 @app.route(&q ...
- jquery属性文档事件等操作
1.jq方法attr removeAttr script标签大部分都是写在body标签上.下面的情况下$符号是拿不到的. 将它放到上面就能拿到$对象了.但是不能获取body里的元素.因为代码执行顺序从 ...
- k83 svc
一,deployment Deployment为Pod和Replica Set下一代Replication Controller)提供声明式更新 1,配置示例 apiVersion: apps/v1 ...
- visual studio故障修复
如果没有安装程序,直接在控制面板——>程序和功能,在列表中找到您安装的vs,右键选择更改,然后程序会启动,做一些准备.然后又三个选项,可以选择修复.
- java计算两个经纬度之间的距离
/** * 计算点 是否在一个固定点的半径范围内 * @2016年10月20日 * @param a 经度1 已知 * @param b 纬度1 已知 * @param x 经度2 * @param ...
- k8s安装之prometheus.yaml
这个系列的东东满多的.要另开系列说明. 这里为了内容连续完成,先贴一个吧,其它configmap,exporter就不展示. 为了保持统一,将prometheus也放到二级目录了. - '--web. ...
- 移动App性能评测与优化-Android内存测试 ,DVM原理
常见的测试方法包括Monkey/UIAutomator类的常规压力测试,大数据/操作的峰值压力测试,长时间运行的稳定性测试等. 前提: 测试准备:版本是纯净版本,不应该附加多余的log和调试用组件. ...
- 关于List集合中元素排序问题
问题描述: 有一个list集合,其中元素是Student对象,根据student的age排序. Student对象 /** * description * * @author 70KG * @date ...