jQuery focus on content of input / textarea - not working properly in IE8
Posted
by katebp
on Stack Overflow
See other posts from Stack Overflow
or by katebp
Published on 2010-05-10T13:10:03Z
Indexed on
2010/05/10
13:14 UTC
Read the original article
Hit count: 198
I want the input fields on my site to select all the text when the user first clicks on them, but in IE8 the text is selected for a split second then reverts back to normal. Works fine in FF.
My js code:
$(document).ready(function () { //HTML DOM document is ready
// Add this behavior to all text fields
$("input[type='text'], textarea").live("focus", function(){
// Select field contents
this.focus();
});
});
Any ideas? I've tried adding ".select()" after "this" and bizarrely enough it works, but throws loads of js errors in FF and IE.
Thanks
© Stack Overflow or respective owner