I’m trying to set the focus on a textarea element when clicking on the headline link.
this is the HTML:
<h2 class="trigger active"><a href="#" id="">header</a></h2>
<div class="toggle_container" style="display:block;">
<div class="block" id="1">
<div>Blah</div>
<textarea name="VALUE">Blah blah</textarea>
</div>
</div>
How can I relatively target the Textarea when clicking the H2?
I prepared a jsfiddle:
http://jsfiddle.net/MkePe/3/
Any help appreciated..
UPDATE:
There was already a working solution, but when there are DIVs that don’t exactly have the right content, everything breaks down. The get(0) method produces a JS error if there’s no Textarea. Is there a flexible solution that keeps this in mind as well? Here’s the non-working-fiddle:
http://jsfiddle.net/3AbHY/3/
Your modified Fiddle HERE
In the h2 click handler :