如何在HTML文本输入字段中隐藏插入符号?
如果我有这样的HTML输入字段:
If I have an HTML input field like this one:
<input type="text" id="mytextfield"/>
所有浏览器似乎都会在该字段中显示插入符号(插入点)。是否有可能通过应用一些CSS或JavaScript来防止这种情况出现?
all browsers seem to show the caret (insertion point) in the field. Is is possible to prevent this from appearing by applying some CSS or javascript?
(我的理由是我的输入是GWT-Ext组合框的基础,就像那些在 http://www.gwt-ext.com/demo/#linkedComboBox - 你不能输入它,但你仍然可以看到插入符,这很烦人。)
(My reason for asking is that my input is the basis of a GWT-Ext combo box like the ones on http://www.gwt-ext.com/demo/#linkedComboBox - you can't type in it, but you can still see the caret, which is annoying).
可以尝试禁用input元素并明确地将其颜色设置为黑色:
What you could try is disable the input element and explicitly set its color to black:
<input type="text" disabled="disabled" style="color: black;" ... />
这应该适用于GWT-Ext组合框(至少在设置萤火虫属性时)。
This should work for the GWT-Ext combo box (at least it did when setting the attributes in firebug).