将文本字段设为选择框

发布于 2024-11-26 17:11:00 字数 160 浏览 0 评论 0原文

当我们单击下拉菜单时,我们看不到光标,我们只看到带有值的整个框被选中,我们可以对文本字段执行相同的操作,因为在文本字段中我看到光标闪烁。

如果感到困惑,请参阅图片。 :D 在此处输入图像描述

When we click on a dropdown we dont see cursor, we just see the whole box with value gets selected, can we do same with text field because in text field I see the cursor blinking.

see image if confused. :D
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

很酷不放纵 2024-12-03 17:11:00

您的意思是要禁用文本输入字段吗? (这就是我能想到的)。试试这个:

<input type="text" disabled="true" />

你想实现什么目标?

编辑:只读:

<input type="text" value="Some value" readonly="readonly" />

我认为这就是您正在寻找的。只读,没有焦点。

<input type="text" value="Some value" onfocus="this.blur()" readonly="readonly" />

编辑3,解决选项卡索引问题:

Previous field: <input type="text" tabindex=1/>
Disabled field: <input type="text" value="Some value" onfocus="this.blur()" readonly="readonly" />
Next Field:     <input type="text" tabindex=2/>

Did you mean you want to disable the text input field? (Thats what I can think). Try this:

<input type="text" disabled="true" />

What are you trying to accomplish?

Edit: Read only:

<input type="text" value="Some value" readonly="readonly" />

I think this is what you are looking for. Read only with no focus.

<input type="text" value="Some value" onfocus="this.blur()" readonly="readonly" />

Edit 3, Solving Tab Index problem:

Previous field: <input type="text" tabindex=1/>
Disabled field: <input type="text" value="Some value" onfocus="this.blur()" readonly="readonly" />
Next Field:     <input type="text" tabindex=2/>
初见终念 2024-12-03 17:11:00

您应该使用 jQuery UI 的自动完成:

http://jqueryui.com/demos/autocomplete/#combobox

You should use jQuery UI's Autocomplete:

http://jqueryui.com/demos/autocomplete/#combobox

乖不如嘢 2024-12-03 17:11:00

如果您不想使用任何 JavaScript 框架,您可以创建自己的 Java 脚本代码来进行自动完成。请查看本页中的示例 -->
AutoComplete 文本框自动完成

If you do not want to use any javascript framework, you can create your own java script code for autocomplete. Please look into the example in this page -->
AutoComplete text box autocomplete

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文