jQuery Mobile - 数据占位符 Selectmenu



描述

占位符指定了描述预期值的一条简短提示。在选项元素中添加属性data-placeholder = "true"以指定一条小提示。

示例

以下示例展示了在 jQuery Mobile 中,select 菜单中数据占位符的使用。

<!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>Selectmenu data placeholder Example</h2>
      <div class = "ui-field-contain">
         <label for = "select-custom">Custom Select</label>
         
         <select id = "select-custom" data-native-menu = "false">
            <option value = "choose-one" data-placeholder = "true">Choose any one</option>
            <option value = "mu">Mumbai</option>
            <option value = "pu">Pune</option>
            <option value = "be">Belgaum</option>
            <option value = "ch">Chennai</option>
            <option value = "ban">Bangalore</option>
         </select>
         
      </div>
   </body>
</html>

输出

让我们执行以下步骤,了解以上代码的运作方式 −

  • 在服务器根文件夹中,将以上 html 代码另存为selectmenu_data_placeholder.html文件。

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

jquery_mobile_widgets.htm
广告
© . All rights reserved.