当我点击一个按钮,我想要这个li元素中的textarea对焦。
<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 your comment... </textarea> <input type="submit" name="" value="Comment" class="comment" id="comment-79"> </form> </div> <div class="clear"></div> </div> </li>
这是我的jQuery代码:
$('.user-status-buttons').click(function() { var id = $(this).attr('id'); $("#commentBox-"+id).slideToggle("fast"); $("#commentBox-"+id+" #StatusMessageMessage").focus(); return false; });