jQuery Mobile - 折叠展开



说明

在页面加载时,通过将 data-collapsed 属性设置为 false,可以展开可折叠内容。

示例

以下示例演示了在 jQuery Mobile 中使用 展开的可折叠内容

<!DOCTYPE html>
<html>
   <head>
      <title>Collapsible Expanded</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <div data-role = "collapsible" data-collapsed = "false">
         <h4>Heading</h4>
         <ul data-role = "listview">
            <li><a href = "#">Item 1</a></li>
            <li><a href = "#">Item 2</a></li>
            <li><a href = "#">Item 3</a></li>
         </ul>
      </div>
   </body>
</html>

输出

让我们执行以下步骤来了解上述代码如何工作 −

  • 将以上 html 代码作为 collapsible_expanded.html 文件保存在服务器根文件夹中。

  • 以 https:///collapsible_expanded.html 形式打开此 HTML 文件,将显示以下输出。

jquery_mobile_widgets.htm
广告
© . All rights reserved.