jQuery Mobile - Icon Set


Advertisements

Description

You can set the icon in the button using ui-icon class and ui-btn-icon-pos_name class for specifying the position for the icon.

Example

Following example describes the use of icon setting in jQuery Mobile Framework.

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <div data-role = "main" class = "ui-content">
         <a href = "#" class = "ui-btn ui-btn-icon-left ui-icon-grid">Grid Button</a>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-d-r">arrow-d-r</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-l">arrow-l</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-r">arrow-r</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-u">arrow-u</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-u-l">arrow-u-l</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-arrow-u-r">arrow-u-r</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-audio">audio</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-calendar">calendar</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-camera">camera</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-carat-l">carat-l</button>
         <button class = "ui-btn ui-btn-icon-left ui-icon-carat-r">carat-r</button>
         <button class = "ui-btn ui-shadow ui-corner-all ui-btn-icon-left 
            ui-icon-check">check</button>
         <button class = "ui-btn ui-shadow ui-corner-all ui-btn-icon-left 
            ui-icon-clock">clock</button>
         <button class = "ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-eye">
            eye</button>
      </div>
   </body>
</html>

Output

Let's carry out the following steps to see how the above code works −

  • Save the above html code as icons_icon_set.html file in your server root folder.

  • Open this HTML file as http://localhost/icons_icon_set.html and the following output will be displayed.

jquery_mobile_icons.htm
Advertisements