how to auto select an input field and the text in it

how to auto select an input field and the text in it

很簡單,範例如下

var input = document.getElementById('myTextInput');

input.focus();   //將焦點移至input
input.select();  //然後將input內的文字全選