Highlight text programmatically when entering polymer paper

I have several input elements from polymer paper in a polymer application. When one of these elements is focused, I would like the text input of the input to be highlighted ( for example, so ), so that if the user is just starting to type, the existing input value is overwritten.

Is there a way to programmatically highlight text?

+4
source share
2 answers

I get it.

inputElement.$.input.select()

It would be nice if it was registered somewhere.

+3
source

, inputElement HTML, <paper-input>. , select() <paper-input>.

HTML:

<paper-input id="my-input" value="[[myInputText]]></paper-input>

JavaScript:

querySelector('#my-input').inputElement.select();
+1

All Articles