简体   繁体   中英

setting focus on text-box

当单击特定div上的div内容时,我正在使用jquery手风琴效果,我是否需要关注div内的文本框?

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();

如果您具有文本框的ID,则可以执行以下操作:

$("#yourtextbox").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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM