如何通过javascript或jquery将输入字段聚焦在Android浏览器上 [英] How to focus an input field on Android browser through javascript or jquery

查看:21
本文介绍了如何通过javascript或jquery将输入字段聚焦在Android浏览器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过 $('#field').focus() 以及在互联网上找到的任何其他方法.没有任何效果.我有一个简单的 html 来重现问题.

I've tried $('#field').focus(), and any other method found on the internet. Nothing worked. I have a simple html that reproduces the problem.

<!DOCTYPE html> 
<html> 
    <head> 
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#field').focus();
            });
    </script>
</head> 
<body>
    <input type="text" id="field" name="field"/>
</body>
</html>

请帮忙!

推荐答案

其实一般的javascript函数focus"在android浏览器中是关闭的.因此,jQuery 焦点功能被停用,因为它使用了上述内容.

Actually, the general javascript function "focus" is deactivated in the android browser. Hence, the jQuery focus function is deactivated since it's using the above.

这篇关于如何通过javascript或jquery将输入字段聚焦在Android浏览器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆