focus to the beginning of the textarea on iphone?
The function focus() doenst开发者_C百科 seem to work for iphone? I need something similar to what they have done for gmail.com when you do a reply.
If you're targeting iPhone/Android (... and don't have to worry about Windows Phone 7 Phone 7 Phone etc.) you can take advantage of the HTML5 autofocus attribute.
So with some markup like this:
<textarea id="the-textarea" autofocus></textarea>
You get an auto-focused textarea.
If you need to position the caret inside the textarea you can use its setSelectionRange method:
$("#the-textarea")[0].setSelectionRange(0, 0);
If you are only targeting Safari, you might try checking out the Safari-specific documentation: http://developer.apple.com/safari/
Firebug (Firefox extension) can also be very helpful in looking at how other developers are implementing things on their sites.
精彩评论