Last active
June 21, 2017 23:44
-
-
Save ewwink/d0092802bcdb866b0b824b4f1a4a6695 to your computer and use it in GitHub Desktop.
Create Javascript HTML5 Color Picker on any page to get CSS color value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){function byId(id){return document.getElementById(id)};byId("colorPicker")||(document.body.innerHTML+='<div id="colorDiv"><input id="colorPicker" type="color"> <input id="colorResult" type="text"></div>');byId("colorDiv").style.cssText="position: fixed;bottom: 0;background-color: #ddfc09;padding: 10px;border: 2px solid #ba734c;";byId("colorPicker").addEventListener("input",function(){byId("colorResult").value=byId("colorPicker").value})})(); | |
/* | |
// uncompressed version | |
(function() { | |
var byId = function(id) { | |
return document.getElementById(id) | |
} | |
if (!byId('colorPicker')) | |
document.body.innerHTML += '<div id="colorDiv"><input id="colorPicker" type="color"> <input id="colorResult" type="text"></div>'; | |
byId('colorDiv').style.cssText = 'position: fixed;bottom: 0;background-color: #ddfc09;padding: 10px;border: 2px solid #ba734c;'; | |
byId('colorPicker').addEventListener('input', function() { | |
byId('colorResult').value = byId('colorPicker').value; | |
}); | |
})(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment