最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to focus a paper-input with Polymer 1.0? - Stack Overflow

programmeradmin2浏览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)

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)

Share Improve this question edited Jun 9, 2017 at 4:25 Max 1,0601 gold badge12 silver badges20 bronze badges asked Jun 12, 2015 at 14:01 vdegennevdegenne 13.3k16 gold badges84 silver badges115 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 12

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();

<paper-input autofocus></paper-input> will automatically focus immediately, or if you'd prefer to control the timing yourself in Javascript you can use paperInput.$.input.focus().

发布评论

评论列表(0)

  1. 暂无评论