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" ...
随机推荐
- HTTP协议复习三--TCP/IP的网络分层模型和OSI 网络分层模型
TCP/IP网络分层模型 第一层叫“链接层”(link layer),负责在以太网.WiFi这样的底层网络上发送原始数据包,工 作在网卡这个层次,使用MAC地址来标记网络上的设备,所以有时候也叫MAC ...
- 关于maven中版本控制问题
之前我们说过Maven的版本分为快照和稳定版本,快照版本使用在开发的过程中,方便于团队内部交流学习.而所说的稳定版本,理想状态下是项目到了某个比较稳定的状态,这个稳定包含了源代码和构建都要稳定. ma ...
- 【Redis】基本数据类型及命令操作(超详细)
一.String 1.1 概述 1.2 相关命令列表 1.3 命令示例 二.List 2.1 概述: 2.2 相关命令列表: 2.3 命令示例: 2.4 链表结构的小技巧: 三.Hashes 3.1 ...
- SQL SERVER-Extendevent系统视图
--获得扩展事件的事件 select name,description from sys.dm_xe_objects where object_type='event' order by name - ...
- spice在桌面虚拟化中的应用系列之二(Linux平台spice客户端的编译安装,支持USB映射)
1.系统环境 1.1 测试环境 centos6.4最小化安装(centos6.x桌面版也适用) 使用yum源为163源加EPEL源 1.2 spice客户端介绍 spice作为远程连接工具,可以支持远 ...
- HTML&CSS基础-前端免费开发工具Hbuilder介绍
HTML&CSS基础-前端免费开发工具Hbuilder介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 工欲善其事必先利其器,想要干好活得有一个好的工具. 一.文本编辑工 ...
- openstack创建实例时aborted: Block Device Mapping is Invalid
问题产生原因: 直接先不创建新卷,点击否,待实例创建完毕后再分配卷.
- 【Vue-01】基础Vue语法+JS复习
Vue学习疑问及总结_SZS 0.vue router 带参数跳转 发送:this.$router.push({path:'/news',query:{id:row.id}}) 接收:var id=t ...
- Excel条件格式的8大用法
1.显示重复值 选中数据区域——开始——条件格式——突出显示单元格规则——重复值——设置格式. 操作演示: 2.利用数据条展示数据 选中数据区域——开始——条件格式——数据条. 操作演示: 3.利用色 ...
- CloudCompare 的简单的使用说明
来自:https://blog.csdn.net/datase/article/details/79797795 File open:打开 save:保存 Global Shift settings: ...