开发者

how to select the content of a focused text

I have a <input type="text" 开发者_如何学JAVAvalue="Hi! Enter Here" >

How to open this in selected mode and cursor on the input field.

We just start writting into it


use jquery focus() function

$('input').focus();

Or better

<input type="text" value="Hi! Enter Here" id="someid">

and

$('#someid').focus();

check working example here.

For select and focus

$('#someid').focus().select();

or

$('#someid').focus(function (){$(this).select();});

On jsfiddle.net


$("input").focus(); 

Read more at http://api.jquery.com/focus/


Set the id of the input

<input type="text" id="myText" value="Hi! Enter Here" >

Then add this jQuery

$(function() {
  $("#myText").focus();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜