jquery - Deselect contents of a textbox with javascript -


I understand that with javascript you can select the contents of a text box with the following code (in jQuery) :

. Select
  $ ("# txt1") ();  

What is the way to do the opposite? To unselect the contents of the text box? The focus of many text boxes set to select the content inside of me is the event. I have many times that I want to focus on a particular text box without choosing it. What I'm planning to do, the focus is calling the event for this particular text box, but then follow it with a call to deselect it.

  $ ("input [type = text]"). Focus (function () {$ (this) .select ();}); // code .... $ ("# txt1"). Focus ();  

Any ideas?

Thank you!

What's this about:

  $ ("input" ). Focus (function () {this.selectionStart = this.selection.and = - 1;});  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -