颜色选择器插件

项目中需要用到颜色插件改变颜色,找了一下,发现了这个插件。1,可以实时地改变颜色,2,颜色选择的范围大

要在head标签里面引进改插件

<script src="js/colpick.js" type="text/javascript"></script>

<link rel="stylesheet" href="css/colpick.css" type="text/css"/>
页面:
 1 # <input type="text" id="picker"></input>
 2 JS
 3 
 4 $('#picker').colpick({
 5 
 6     layout:'hex',
 7 
 8     submit:0,
 9 
10     colorScheme:'dark',
11 
12     onChange:function(hsb,hex,rgb,el,bySetColor) {
13 
14         $(el).css('border-color','#'+hex);
15 
16         // Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
17 
18         if(!bySetColor) $(el).val(hex);
19 
20     }
21 
22 }).keyup(function(){
23 
24     $(this).colpickSetColor(this.value);
25 
26 });
27 CSS
28 
29 #picker {
30 
31     margin:0;
32 
33     padding:0;
34 
35     border:0;
36 
37     width:70px;
38 
39     height:20px;
40 
41     border-right:20px solid green;
42 
43     line-height:20px;
44 
45 }

 

效果图:

 插件下载地址:https://git.oschina.net/wxwphp/col.git

 

转载于:https://www.cnblogs.com/wxw1314/p/6030087.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值