1

I have a spinner - not a text field or a textarea

<input type="number" />

enter image description here

It would be nice to not have the blinking caret in the field when the control is clicked.

enter image description here

The answer to How to hide the caret in an HTML text input field?

does of course not work since the spinner does not run when the field is disabled or readonly.

Neither does Hide textfield blinking cursor which is not a spinner

Also jQuery UI spinner has the same issue

Community
  • 1
  • 1
mplungjan
  • 169,008
  • 28
  • 173
  • 236

2 Answers2

1

css:

.your-field{
    color: transparent;
}
  1. add wrapper to the field with position: relative; and a span/div/whatever after the field with position: absolute.

  2. position span correctly (it's top-left should overlap with input text start position)

  3. add event handler on keyup/keydown/custom arrow click/any event that changes input val
  4. handler function (jQuery):

    function() { $('.your-absolute-positioned-element').text( $('.your-field').val() ); }
    
Michael Malinovskij
  • 1,422
  • 8
  • 22
1

The blink is part of the native input representation - you'd have to hack it to A) make said input invisible and B) reproduce its content elsewhere.

A) I'd suggest using colour: transparent. If older browser support (I know old IEs won't like this) you can go for visibility: hidden or other techniques, but then addressing focus will be tough.

B) Create a wrapper around the input with position: relative, then a span immediately afterwards that will match the input value whenever it changes.

Here's a simple codepen example:

http://codepen.io/barneycarroll/pen/beFgm

Barney
  • 16,181
  • 5
  • 62
  • 76