Demo - Color Input
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<div class="container">
<h1>
Color Input
<div id="output">
Select a background for me!
</div>
</h1>
<p>
Use the InputColor control to edit color values
when you have only a little room:</p>
<div id="theInputColor"></div>
<p>
Use the ColorPicker control to edit color values
when you have enough room:</p>
<div id="theColorPicker"></div>
</div>
CSS
.wj-dropdown {
margin-bottom: 18px;
}
#output {
float: right;
font-size: 12px;
border: 1px solid grey;
padding: 12px;
xmargin: 12px;
}
JavaScript
onload = function() {
// InputColor
var theInputColor = new wijmo.input.InputColor('#theInputColor', {
placeholder: 'Select the color',
valueChanged: function(s, e) {
setBackground(s.value);
}
});
// ColorPicker
var theColorPicker = new wijmo.input.ColorPicker('#theColorPicker', {
valueChanged: function(s, e) {
setBackground(s.value);
}
});
// show the color that was selected
function setBackground(color) {
document.getElementById('output').style.background = color;
theInputColor.value = color;
theColorPicker.value = color;
}
}