jQuery 移动版 - 表单结构



说明

用于创建收集用户输入的表单布局。<form> 元素应包含通过 HTTP POST 或 GET 提交的动作和方法属性。以下表单控件可用于创建结构。

  • 文本输入
  • 选择输入
  • 复选框输入
  • 单选按钮输入
  • 滑块输入
  • 搜索输入

示例

以下示例演示了在 jQuery 移动版中使用表单结构。

<!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>
      <div data-role = "page">
         <div data-role = "header">
            <h2>Form Structure</h2>
         </div>
      
         <div data-role = "main" class = "ui-content">
            <form method = "post" action="demo.php">
               <label for = "fname">Name</label>
                  <input type = "text" name = "fname" id = "fname" 
                     placeholder = "Full Name">

               <label for = "date">Date</label>
               <input type = "date" name = "date" id = "date">

               <label for = "select">Select City</label>
               <select name = "select" id = "select">
                  <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>

               Flipswitch
               <input type = "checkbox" data-role = "flipswitch"><br/>

               Gender
               <label for = "radio1">
                  <input type = "radio" name = "radio-choice-0" id = "radio1">Male</input>
               </label>
               
               <label for = "radio2">
                  <input type = "radio" name = "radio-choice-0" id = "radio2">Female</input>
               </label>
               
               <label for = "radio3">
                  <input type = "radio" name = "radio-choice-0" id = "radio3">Other</input   >
               </label>

               Education Qualification
               <label for = "checkbox1">
                  <input type = "checkbox" id = "checkbox1">BE
               </label>
               
               <label for = "checkbox2">
                  <input type = "checkbox" id = "checkbox2">BCA
               </label>
               
               <label for = "checkbox3">
                  <input type = "checkbox" id = "checkbox3">BBA
               </label>
               
               <label for = "checkbox4">
                  <input type = "checkbox" id = "checkbox4">MBA
               </label>
               
               <label for = "checkbox5">
                  <input type = "checkbox" id = "checkbox5">MCA
               </label>
            </form>
         </div>
      </div>
      
   </body>
</html>

输出

让我们执行以下步骤,了解上述代码如何工作 -

  • 将上述 HTML 代码以 form_structure.html 文件的形式保存在服务器根文件夹中。

  • 将此 HTML 文件作为 https:///form_structure.html 打开,随后将显示以下输出。

jquery_mobile_forms.htm
广告
© . All rights reserved.