问题
If I have an HTML input field like this one:
<input type="text" id="mytextfield"/>
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?
(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).
回答1:
What you could try is disable the input element and explicitly set its color to black:
<input type="text" disabled="disabled" style="color: black;" ... />
This should work for the GWT-Ext combo box (at least it did when setting the attributes in firebug).
来源:https://stackoverflow.com/questions/4333919/how-to-hide-the-caret-in-an-html-text-input-field