I want to know how to make a color picker with jQuery that will allow you to click somewhere on the page and return the hex color value of the color that you clicked on.
I know that it is possible with either javascript or jquery as not only do they have lots of color picker plugins, but I have and extension for Chrome that has that same exact functionality.
Any ideas?
Bind a global
clickormouseupevent listener. Then, usecanvasto obtain the pixel information. The pixel positions can be retrieved through theeventobject (event.pageX,event.pageY).See below for an example, which should work in future versions of FireFox. Currently, for security reasons, the
drawWindowmethod is disabled for web pages. It should work in extensions, though. If you’re truly interested, see the links for the similar methods in Chrome, Safari and Internet Explorer.References
canvas