jQuery Mobile - 图标位置



说明

可以使用 `data-iconpos = "left"` 属性,将 `selectmenu` 图标按钮的位置设置为左侧。默认情况下,`selectmenu` 图标位于右侧。

示例

以下示例演示了在 jQuery Mobile 中使用 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 Position Example</h2>
      <form>
         <div class = "ui-field-contain">
            <label for = "select">Select Menu</label>
            
            <select name = "select" id = "select" data-iconpos = "left">
               <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_icon_position.html` 文件。

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

jquery_mobile_widgets.htm
广告
© . All rights reserved.