Search code examples
javascriptpolymerpolymer-1.0

How to focus a paper-input with Polymer 1.0?


This question is a follow-up to this one: polymer focus() on <paper-input> or <core-input> element

How can I focus in a paper-input element using the Javascript API ?

(using Polymer 1.0)


Solution

  • If you have an element:

    <paper-input id="my-input" label="What's on your mind?"></paper-input>
    

    paper-input is a wrapper for business logic and stylish of a more deep-down input element which you can reach through:

    document.getElementById('my-input').$.input
    

    To focus, just write:

    document.getElementById('my-input').$.input.focus();