How to select the entire text of the form when you click on it?
  • select visually (color, size, border, ...) or select text as ctrl + a? - Specter


1 answer 1

​$( function(){ $('input').click( function(){ $(this).select() }) }) 
  • one
    instead of $ (this) .select () it’s better to use this.select () to save on the face. - lampa
  • one
    About yes XD ... - Yakovlev Andrei
  • the most economical option (if only one form is used) <input onclick = "this.select ()"> -
  • 3
    tests: jsperf.com/selecttest123/3 As you can see, the difference between $ (this) and this is minimal. And option @ Ь_ zhzhot =) - Yakovlev Andrey
  • @Andrey Yakovlev, anyway, for every click, a jQuery object is created. - lampa