关注工具提示中的文本字段
Showing a 'share' link in a textfield within a tooltip using qTip2.
The tooltip itself works fine, but I'd also like to get the textfield to have focus with all the text selected. Found this, but somehow the focus/click + select doesn't seem to be working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在调用
show
回调后,似乎有什么东西从文本输入中移除了焦点;可能只是时间问题,也可能是 qTip2 中的某些内容改变了焦点。您可以尝试使用
setTimeout
,时间为一旦浏览器重新获得控制权,零就会触发函数(这应该在所有 qTip2 内容完成后发生)。这适用于 Chrome、Safari、Firefox 和 Opera:演示: http://jsfiddle.net/ambigously/ npZgv/
Something seems to be removing the focus from the text input after the
show
callback is called; could just be a timing issue, could be something in qTip2 changing the focus.You can try using a
setTimeout
with a time of zero to trigger a function once the browser gets control back (and that should happen after all the qTip2 stuff has finished). This works for me in Chrome, Safari, Firefox, and Opera:Demo: http://jsfiddle.net/ambiguous/npZgv/
如果有人对另一种方法感兴趣,这是我从 Craig Thompson(qTip 创建者)那里得到的答案,它使用自动对焦事件
In case any one is interested in another approach, here's the answer I got from Craig Thompson (qTip creator), which uses the autofocus event