colorpicker.js颜色选择器的使用
初始化
<body>
<div class="abc">
<div class="picker" id="color-picker">
</div>
</div>
</body>
<script>
new Colorpicker({
el: "color-picker",
color: "#000fff", // 初始色
change: function (elem, hex) {
elem.style.backgroundColor = hex;
console.log(elem,hex);// dom元素-elem;十六进制颜色-hex
}
})
</script>
显示效果

其他
js源代码里
this.util.css(div, {
"position": "absolute",
"z-index": 2,// 这个设大点,动态生成的div会显示在最上边(有的页面本身比2大,会被遮挡)
"display": 'none', // 初始化完成后是否直接出现弹窗
"left": left + "px",
"top": top + this.bindElem.offsetHeight + "px"
});

浙公网安备 33010602011771号