当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


jQuery Mobile Selectmenu preventFocusZoom用法及代码示例


jQuery Mobile 是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。

在本文中,我们将使用 jQuery Mobile Selectmenu PreventFocusZoom 选项。此选项用于在自定义选择获得焦点时暂时禁用页面缩放,从而防止 iOS 设备将页面缩放到选择中。默认情况下,iOS 通常会放大表单控件,而这种行为在移动优化布局中通常是不必要的且具有侵入性。

句法:

使用 PreventFocusZoom 选项初始化选择菜单。

$( ".selector" ).selectmenu({
preventFocusZoom: true
});
  • 设置 PreventFocusZoom 选项。

    $( ".selector" ).selectmenu("option", 
        "preventFocusZoom", true);
  • 获取 PreventFocusZoom 选项。

    var shadow = $( ".selector" )
        .selectmenu( "option", "preventFocusZoom" );

CDN 链接:首先,添加项目所需的 jQuery Mobile 脚本。

<link rel=”stylesheet” href=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css”>
<script src=”//code.jquery.com/jquery-3.2.1.min.js”></script>
<script src=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js”></script>

例子:此示例说明了 jQuery Mobile 选择菜单防止焦点缩放选项。

HTML


<!doctype html> 
<html lang="en"> 
  
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport"
          content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" 
          href= 
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css"> 
    <script src= 
"//code.jquery.com/jquery-3.2.1.min.js"> 
    </script> 
    <script src= 
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js"> 
    </script> 
</head> 
  
<body> 
    <center> 
        <div data-role="page"> 
            <h1 style="color:green;"> 
                GeeksforGeeks 
            </h1> 
            <h3>jQuery Mobile Selectmenu preventFocusZoom Option</h3> 
            <div role="main" class="ui-content"> 
                <label for="GFG" class="select"> 
                    GeeksforGeeks Courses: 
                </label> 
                <select name="GFG" id="GFG" 
                        data-native-menu="false"> 
                    <option value="C"> 
                      C Programming 
                    </option> 
                    <option value="CPP"> 
                      C++ Programming 
                    </option> 
                    <option value="JAVA"> 
                      Java Programming 
                    </option> 
                    <option value="overnight"> 
                      Python Programming 
                    </option> 
                    <option value="WEB"> 
                      Web Development 
                    </option> 
                </select> 
            </div> 
            <input type="button" id="Button" 
                   value="Value of the preventFocusZoom option"> 
            <div id="log"></div> 
        </div> 
    </center> 
    <script> 
        $(document).ready(function () { 
            $("#GFG").selectmenu({ 
                preventFocusZoom: true 
            }); 
            $("#GFG").selectmenu("option", "preventFocusZoom", true); 
            $("#Button").on('click', function () { 
                var a = $("#GFG").selectmenu("option", "preventFocusZoom"); 
                $('#log').html(a); 
            }); 
        }); 
    </script> 
</body> 
  
</html>

输出:

jQuery Mobile Selectmenu preventFocusZoomOption

jQuery Mobile 选择菜单阻止FocusZoomOption

参考:https://api.jquerymobile.com/selectmenu/#option-preventFocusZoom



相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 jQuery Mobile Selectmenu preventFocusZoom Option。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。