开发者

setting focus on text-box

开发者 https://www.devze.com 2023-01-05 04:17 出处:网络
I am using jquery accordion effect when the clicks ona particular div the content of div appears ,i need 开发者_运维技巧the focus on a text-box inside the div?If you have the id of the text box, you c

I am using jquery accordion effect when the clicks on a particular div the content of div appears ,i need 开发者_运维技巧the focus on a text-box inside the div?


If you have the id of the text box, you could do the following:

$("#yourtextbox").focus();


You'll need to make use of the jQuery focus method:

$(div).click(function(){
  $(this).children("#win").focus();
});

Or if it's the only textbox with that ID (which it should be if you're using an ID), just call:

$("#win").focus();


You can use Jquery function focus(), somthing like this: (for first input field in a div without id)

<div id="myDiv" onclick="$('input', this).focus();">
<input type="text" name="some_name" value="">
</div>
0

精彩评论

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