jQuery Textarea focus -
when click button want textarea
in li
element focus.
<li class="commentblock" id="commentbox-79" style="display: list-item;"> <div> <div class="grid userimageblocks"> <div class="imgsmall"> <img width="35" height="35" alt="image" src="/bakasura1/files/images/small/1288170363aca595cabb50.jpg"> </div> </div> <div class="grid usercontentblocks alpha omega"> <form accept-charset="utf-8" action="/bakasura1/account/savecomment" method="post"> <div style="display: none;"> <input type="hidden" value="post" name="_method"> </div> <input type="hidden" id="statusmessagereplypid" value="79" name="data[statusmessagereply][pid]"> <input type="hidden" id="statusmessagereplyitemid" value="1" name="data[statusmessagereply][item_id]"> <input type="hidden" id="statusmessagereplycommentersitemid" value="1" name="data[statusmessagereply][commenters_item_id]"> <textarea id="statusmessagereplymessage" name="data[statusmessagereply][message]"> write comment... </textarea> <input type="submit" name="" value="comment" class="comment" id="comment-79"> </form> </div> <div class="clear"></div> </div> </li>
this jquery
code:
$('.user-status-buttons').click(function() { var id = $(this).attr('id'); $("#commentbox-"+id).slidetoggle("fast"); $("#commentbox-"+id+" #statusmessagemessage").focus(); return false; });
based on comment in reply jacob, perhaps want:
$('.user-status-buttons').click(function(){ var id = $(this).attr('id'); $("#commentbox-"+id).slidetoggle("fast", function(){ $("#commentbox-"+id+" #statusmessagereplymessage").focus(); }); return false; });
this should give #statusmessagereplymessage
element focus after slide effect has finished.
Comments
Post a Comment