如何在默认情况下隐藏jQmobile页面

Eug*_*ray 0 html javascript jquery jquery-mobile

你如何隐藏jquery mobile包含的页面.我想拥有该网站的移动版本和桌面版本,但移动版本会自动加载.我该如何改变?

代码在这里:

<!DOCTYPE html>
<html>
    <head>
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
        <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>

        <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />
        <link href="../global/global.css" rel="stylesheet" />
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script language="javascript" type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div >
        <!-- The View Page (Summary) -->
        <div data-role="page" id="summary">
            <div data-role="header">
            </div>
            <div data-role="main" class="ui-content">
                <div class="jumbotron container">
                    <center>
                        <img src="removeLogo.jpg" />
                    </center>
                    <h2 class="txt-center"><u>Controls</u></h2>
                    <a class="btn btn-default">View</a>
                </div>
            </div>
            <div data-role="footer">
            </div>
        </div>

        <div data-role="page" id="summary">
            <div data-role="header">
            </div>
            <div data-role="main" class="ui-content">
                <div class="jumbotron container">
                    <center>
                        <img src="removeLogo.jpg" />
                    </center>
                    <h2 class="txt-center"><u>Controls</u></h2>
                    <a class="btn btn-default">View</a>
                </div>
            </div>
            <div data-role="footer">
            </div>
        </div>
    </bod
Run Code Online (Sandbox Code Playgroud)

Y>

Jam*_*ice 6

脚本运行时DOM尚未就绪.将它放在DOM ready事件处理程序中:

$(function () {
    // Interact with the DOM in here
});

// Or, the slightly longer version
$(document).ready(function () {
    // Interact with the DOM in here
});
Run Code Online (Sandbox Code Playgroud)

或者,将JavaScript移动到正文的末尾(就在结束</body>标记是常见位置之前,但在您需要引用的元素之后的任何位置都可以).通过这样做,在解析脚本时,浏览器已经解析了前面的标记,并且有一个几乎完整的DOM树可供您访问.

  • 十分之十是这个问题:P (2认同)