+ 3

How to allow user to use the browser's color picker to choose/input colour?

15th Sep 2019, 4:35 AM
SSki11
SSki11 - avatar
3 Respostas
+ 1
By using <input type = "color"> which provides the browser's color picking interface on being clicked. In case the browser doesn't support any colour picker, a text box is displayed to enter a hexadecimal. NOTE: The only value type returned and accepted by such input is a string containing a 7-character hexadecimal ('#' followed by the 6-character color representation). DEFAULT VALUE: The standard default value of this type of input is "#000000" (black). Use the 'value' attribute of the input element and set its value to a valid hexadecimal (read the above note) to set your own default value. EVENT HANDLING: One can use different event handlers to handle the color input, but the specific ones for this purpose are oninput and onchange. If someone requires an immediate action to be performed on clicking the input, onclick can also be used together with the other ones. EXAMPLE: https://code.sololearn.com/WIxh2eJ7842q/?ref=app
15th Sep 2019, 4:36 AM
SSki11
SSki11 - avatar
+ 1
Thomas Williams Will it work if I simply delete the description of this question? I don't think that answering a question posted by self violates the rules of SoloLearn if it's a good question. I mentioned that in the description so that it doesn't look weird that someone questions and answers himself. If this helps others, there shouldn't be any problems, right?
15th Sep 2019, 11:33 AM
SSki11
SSki11 - avatar
- 1
The Q&A forum is for *questions* related to coding. Tutorials are not allowed here, and should rather be placed on your feed where it belongs https://www.sololearn.com/Discuss/1316935/?ref=app
15th Sep 2019, 6:03 AM
Trigger
Trigger - avatar