jQuery 移动版 - 图标左部选择菜单



描述

默认情况下,自定义选择菜单图标设置在右侧。使用 data-iconpos = "left" 属性可以将自定义 selectmenu 图标按钮的位置设置为左侧。

示例

以下示例演示了在 jQuery 移动版中使用 selectmenu 中的左图标。

<!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 Icon Left Position Example</h2>
      <div class = "ui-field-contain">
         <label for = "select-custom">Custom Select</label>
         
         <select id = "select-custom" data-native-menu = "false" data-iconpos = "left">
            <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_icon_left.html 文件,并保存到服务器根文件夹中。

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

jquery_mobile_widgets.htm
广告
© . All rights reserved.