rolling stone rolling stone - 9 months ago 41
HTML Question

How to Set Focus on Input Field using JQuery

Given the following HTML structure:

<div class="wrapper">
<div class="top">
<a href="" class="link">click here</a>
<div class="middle">
some text
<div class="bottom">
<input type="text" class="post">
<input type="submit">

which will be repeated several times on the page, how do I set the focus on the input field in the
div when a user clicks on the link in the

I am currently making the
div appear successfully on click using the JQuery code below, but can't seem to figure out how to set focus on the input field at the same time.

$('.link').click(function() {



Try this, to set the focus to the first input field: