Set the color of the cursor to red inside an input field:
document.getElementById("input1").style.caretColor = "red";
Try it Yourself »
The caretColor property specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable.
Property | |||||
---|---|---|---|---|---|
caretColor | 57.0 | 79.0 | 53.0 | 11.1 | 44.0 |
Return the caretColor property:
object.style.caretColor
Set the caretColor property:
object.style.caretColor = "auto|
color|initial|inherit"
Value | Description |
---|---|
auto | Default. Browsers uses the currentColor for the caret |
color | Specifies a color to use for the caret. All legal color values can be used (rgb, hex, named-color, etc). For more information on legal values, read our CSS Colors Tutorial |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | auto |
---|---|
Return Value: | A String, representing the caret color of an element |
CSS Version | CSS3 |
CSS reference: caret-color property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!