当键盘出现时,焦点在textarea上

时间:2014-03-05 04:45:01

标签: html ios keyboard touch textarea

我有一个Web应用程序(不是android应用程序)

我的页面中有很多textarea,例如bellow,如果我点击iPad上的textarea,keyborad就出现了,我在我的textarea中失去了焦点。

我的问题:即使键盘出现,我怎样才能保持焦点?不使用jquery mobile。

为例

<html>
    <head>
        <title>My Page</title>
    </head>

    <body>
        <form name="myform" action="" method="POST">
            <div align="center">
                This is outside the area<br><br>
                <textarea cols="40" rows="1" name="myname">
                      Now we are inside the area - which is nice.
                </textarea>
                <br><br>
                And now we are outside the area again.
            </div>
             <div align="center">
                This is outside the area<br><br>
                <textarea cols="40" rows="1" name="myname">
                      Now we are inside the area - which is nice.
                </textarea>
                <br><br>
                And now we are outside the area again.
            </div>
             <div align="center">
                This is outside the area<br><br>
                <textarea cols="40" rows="1" name="myname">
                      Now we are inside the area - which is nice.
                </textarea>
                <br><br>
                And now we are outside the area again.
            </div>
        </form>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以尝试HTML 自动对焦属性:

<textarea cols="40" rows="1" name="myname" autofocus>
  Now we are inside the area - which is nice.
</textarea>

不确定onclick="autofocus"是否正常工作。 (不相信它。你将需要javascript)