Gae*_*ala 6 html javascript php html5
<label for="background-color">Choose a color for background :</label>
<input id="background-color" type="color" />
Run Code Online (Sandbox Code Playgroud)
我希望这返回颜色名称而不是颜色代码,例如"蓝色"而不是"#0000ff".
$(document).ready(function(){
$("#showPaletteOnly").spectrum({
showPaletteOnly: true,
showPalette:true,
hideAfterPaletteSelect:true,
color: 'blanchedalmond',
change: function(color) {
printColor(color);
},
palette:["red", "green", "blue"],
});
});
function printColor(color) {
alert(color.toName());
//var text = "You chose... " + color.toHexString();
//$(".label").text(text);
}
</script>Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://bgrins.github.io/spectrum/spectrum.js"></script>
<link rel="stylesheet" type="text/css" href="https://bgrins.github.io/spectrum/spectrum.css">
<h2>Palette Only</h2>
<input type='text' id="showPaletteOnly"/>
<br />
<span class='label'>Choose a color</span>Run Code Online (Sandbox Code Playgroud)