简体   繁体   中英

Why HTML <input type=“color”> does not work at first?

I am creating a text editor with HTML and I want to change font color.

<input id="fore-color" type="color" value="#ffffff" onchange="changeWithArgs('foreColor', this.value)">

When I open it on Chrome, at first it can't implement a color till I choose one of basic colors. After that it starts to work normally,but how can I choose my prefered color at once?

Issue is provided in photo . Also it can't change color | solid property. Please help. Thanks in advance.

You have to select the color from basic color or custom colors. But by default whatever color you mentioned in the value attr will be the default one selected once the page is loaded.

实际上,当您选择颜色时,最右边的条设置为黑色(因为将黑色三角形设置为黑色)。...除了最右边的条之外,您还必须更改黑色三角形的位置才能更改颜色

You have to specify the type of input in HTML; for example, type="text" type="checkbox" etc. There is no value "color" for the type attribute of an input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM