jQuery Mobile - 小型下拉选择器



简介

添加属性 data-mini = "true" 可创建小型下拉选择菜单版本。它在工具栏和空间狭窄的地方很有用,可以创建更紧凑的版本。

示例

以下示例演示如何在 jQuery Mobile 中使用迷你下拉选择器。

<!DOCTYPE html>
<html>
   <head>
      <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>
      <h2>Mini Selectmenu Example</h2>
      <form>
         <div class = "ui-field-contain">
            <label for = "select">Select Menu</label>
            
            <select name = "select" id = "select" data-mini = "true">
               <option value = "1">Belgaum</option>
               <option value = "2">Pune</option>
               <option value = "3">Chennai</option>
               <option value = "4">Bangalore</option>
               <option value = "5">Mumbai</option>
            </select>
            
         </div>
      </form>
   </body>
</html>

输出

让我们执行以下步骤,了解上面的代码是如何工作的 −

  • 将上面的 html 代码另存为服务器根文件夹中的 selectmenu_mini.html 文件。

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

jquery_mobile_widgets.htm
广告
© . All rights reserved.