更改默认文本“输入位置”在 Google 地图 Places API 中
我在互联网上查找了所有问题,试图找到问题的答案,而我找到的最接近答案的是另一个 Stack Overflow 问题,此处:如何更改 Google Maps API 地点自动完成中的默认文本
问题是OP 没有和我有完全相同的要求,或者他们没有说清楚。
我正在寻找一种方法来获取文本输入字段中的默认“输入位置”,并将其替换为其他内容,同时保持相同的功能。即让文本在焦点上消失,如果没有输入文本,则在失去焦点时重新出现。
在我当前的尝试中,我尝试使用 jQuery 插件替换文本。它在页面加载时可视化地工作,但是当单击时,“输入位置”会再次弹出,并在输入文本或输入失去焦点时消失(而不是文本输入字段按预期变为空白)。
有人可以在这里给我指点吗?
提前致谢。
I've looked all over the internet trying to find an answer to my problem, and the closest thing I've found to an answer is another Stack Overflow question, here: How do i change the default text in Google Maps API Places Autocomplete
The problem is that either the OP did not have quite the same requirements as myself, or they didn't quite make it clear if they do.
I'm looking for a way to take the default "Enter a Location" in the text input field, and replace it with something else while keeping the same functionality. i.e. have the text disappear on focus, and reappear when it loses focus if no text was entered.
In my current attempt, I've tried to replace the text using a jQuery plugin. It works visually on pageload, but when clicked, "Enter a Location" pops up again, and disappears when text is entered, or the input loses focus (as opposed to the text entry field going blank as intended).
Can anyone give me a pointer here?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需设置要附加自动完成功能的
input
元素的placeholder
属性即可:这在 文档:
Just set the
placeholder
attribute of theinput
element to which you are attaching the autocomplete to whatever you want:This is detailed in the documentation: