How to programmatically disable the automatic selection of <input type = text> elements?

Then the user uses TAB or SHIFT-TAB to "jump" to a specific text field and that the text field has a value in it, then this value will be automatically selected. I would like to disable this behavior.

I assume this can be done inside the focusin event handler:

$("input:text").focusin(function() { // "un-select" the value and place the text-cursor // at the beginning or end of the value }); 
+2
javascript jquery html
source share
1 answer
 $(function() { $('input').bind('focus', function(e) { return false; }); }); 

Using jQuery 1.4.3+, you can use the shortened version:

 $(function() { $('input').bind('focus', false); }); 

Example: http://www.jsfiddle.net/P8LDB/

+3
source share

All Articles