Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unselect textbox on blur with jQuery in IE8

I'm trying to have the default behavior of a form select (or highlight) the text when you tab to the next input. I've had to add the .select() function on my password form fields for this to work in IE8. Is there an equivalent to the jquery .select() for deselecting text?

       $("#MyTextBox").focus(function() {
            $(this).select();
        });

        $("#MyTextBox").blur(function() {
            // Deselect here
        });
like image 304
Victor Avatar asked Dec 29 '22 01:12

Victor


1 Answers

Not that I am aware, however this ought to work for you:

$(this).val($(this).val());

Here you set the value of the field to itself. the cursor should automatically be put on the end.

like image 151
James Wiseman Avatar answered Jan 10 '23 06:01

James Wiseman