Lalchand
Lalchand

Reputation: 7827

setting focus on text-box

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?

Upvotes: 0

Views: 237

Answers (3)

Meduza
Meduza

Reputation: 542

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>

Upvotes: 1

djdd87
djdd87

Reputation: 68456

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

Upvotes: 1

xil3
xil3

Reputation: 16439

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

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

Upvotes: 1

Related Questions