HTML5 input color's default color

前端 未结 7 2194
感情败类
感情败类 2021-02-01 01:16

The input type=\"color\" has a default color which is black: #000000.

Even if I give it an empty value...

7条回答
  •  耶瑟儿~
    2021-02-01 01:49

    While using hexcode for value attribute in , one thing I noticed is that it has to be six digits, if for white you use #fff, it does not work. It has to be #ffffff.

    The same thing happens when setting it through javascript. document.querySelector('input[type="color"]').value = '#fff' does not work. The color remains black. You have to use document.querySelector('input[type="color"]').value = '#ffffff' for it to work.

    Something to be careful about.

提交回复
热议问题