Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cursor from text box?

Tags:

html

Here is my code:

<table>
<tr>
<td><input type="text" value="test1" readonly  /></td>
</tr>
<tr>
<td><input type="text" value="test2"  readonly /></td>
</tr>
<tr>
<td><input type="text" value="test3" readonly /></td>
</tr>
</table>

How do I remove the cursor from the text box?

like image 221
Moumita Avatar asked Jul 30 '11 17:07

Moumita


2 Answers

If the browser shows the insertion caret when the readonly attribute is set on an input[type="text"] element, you may be able to use the caret-color CSS property to make the caret transparent:

.caret-hidden {
  caret-color: transparent;
}
<input class="caret-hidden" type="text" readonly>
like image 172
Grant Miller Avatar answered Sep 28 '22 06:09

Grant Miller


Poor man's solution: transmit value in a hidden form item (<input type="hidden">) and display it in a regular HTML container (<p></p>, <div></div> or whatever).

like image 39
Álvaro González Avatar answered Sep 28 '22 07:09

Álvaro González