Hex value board
by rdenver6
HTML
<div>
<input id="tempInput" type="text">
</div>
<div id="container">
<div>
#b0d036
</div>
<div>
#0277c6
</div>
<div>
#e2f2f9
</div>
<div>
#006F7A
</div>
<div>
#D2DA40
</div>
</div>
CSS
#container {display:flex;flex-wrap:wrap;}
#container > div {height:50px; margin:10px; width:80px; border:1px solid black;}
JavaScript
$( "#container div" ).each(function( index ) {
var bg = $(this).text();
$(this).css("background-color",bg);
});
$( "#container div" ).click(function() {
var text = $(this).text();
console.log(text);
$("#tempInput").val(text);
$("#tempInput").select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
$("#tempInput").val('');
});