jQuery Mobile - Form Buttons

jQuery Mobile supports button styles that can be customized according to your needs. The <input> element is used to code button in forms. Following are the attributes used to modify the style of buttons.

Sr.No. Attribute Value Description
1 data-corners true/false Sets the corner for the buttons.
2 data-icon Different icons Sets different icon on the button.
3 data-iconpos left/right/bottom/ top/notext Sets the position for the icon on the button.
4 data-inline true/false Sets the button inline.
5 data-mini true/false Sets the button small.
6 data-shadow true/false Sets the shadow for the button.


Following example demonstrates the use of form buttons in jQuery Mobile.

<!DOCTYPE html>
      <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>
      <div data-role = "page">
         <div data-role = "header">
            <h2>Form Button</h2>
         <div data-role = "main" class = "ui-content">
            <form method = "post" action = "jquery_mobile/demo.php">
               <label for = "fname">First Name</label>
               <input type = "text" name = "fname">
               <label for = "lname">Last Name</label>
               <input type = "text" name = "lname">

               <input type = "submit" value = "Submit Button" data-inline = "true" 
                  data-corner = "true">
               <input type = "reset" value = "Reset Button" data-inline = "true" 
                  data-corner = "true">


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

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

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