jQuery mobile 學習12 表單的使用方法及訪問裝置判斷

來源:互聯網
上載者:User

標籤:jquery mobile   布局   表單   

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE html><html><head>    <meta charset="utf-8" />    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">    <link rel="stylesheet" href="./css/jquery.mobile-1.3.0.css"/>            <script type="text/javascript" src="./js/jquery-1.8.3.js"></script>        <script type="text/javascript">        /*判斷裝置的屬性*/var deviceAgent = navigator.userAgent.toLowerCase();  var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);  if(agentID.indexOf("iphone")>=0){   alert("iphone");  }  if(agentID.indexOf("ipod")>=0){   alert("ipod");  }  if(agentID.indexOf("ipad")>=0){   alert("ipad");  }  if(agentID.indexOf("android")>=0){   alert("android");  }     </script>        <script type="text/javascript" src="./js/jquery.mobile-1.3.0.js"></script></head><body>   <div data-role="page" id="a">   <div data-role="header" data-position="fixed" data-theme="b">   <h2>   a頁面的標題   </h2>   </div>      <!--    提交表單jQuery Mobile 自動採用 Ajax 的方式提交表單,預設的 method 為 get ,action 為當前頁面的相對路徑,在表單頁面和結果頁面之間會有平滑的轉場過渡,並且可以在表單上使用 data-transition 指定轉場效果。如果不想使用 Ajax 的方式提交表單,可以在全域事件禁用 Ajax (如何全域禁止 Ajax 並不在本文討論範圍,但會在本系列的後續文章中作詳細說明)或是在 form 上添加 data-ajax="false" 屬性,下面是 data-transition 的所有可取值。 slide 滑動(預設值,從左至右滑出), slideup(從下至上滑出), slidedown(從上至下滑出), pop(從中心漸顯展開), fade(漸顯), flip(翻轉)。    -->               <!-- 由於 jQuery Mobile 使用 Ajax 導航,因此不同的 page 可以同時載入到一個 DOM 中,因此 form id 必須整站唯一以保證每個 DOM 的表單 id 都是不同的。 每一個表單元素應該要有相應的 label 對應,label 的 for 值要與元素的 id 相同,使其在語義上相關,並且可以使用一個帶有 data-role="fieldcontain" 屬性的 div 或 fieldset 容器包裹, jQuery Mobile 會自動在容器底部增加一條細邊框作為分隔。    -->         <div data-role="content"><textarea rows="10" cols="20">jack</textarea><input type="password"><div data-role="fieldcontain">      <label for="slider">開關</label>      <select name="slider" id="slider" data-role="slider">          <option value="off">關閉</option>          <option value="on">開啟</option>      </select>  </div>  <div data-role="fieldcontain">      <label for="slider">滑杆</label>      <input type="range" name="slider" id="slider" value="0" min="0" max="100"  />  </div>  <!-- 單選結果選項的下拉框 --><!--  data-native-menu="false" 這個屬性很重要,沒有就不能達到JQM的效果哦 --><div data-role="fieldcontain">      <label for="select-choice-1" class="select">挑選清單</label>      <select  data-native-menu="false" name="select-choice-1" id="select-choice-1">          <option value="12h">12小時</option>          <option value="1d">一天</option>          <option value="2d">兩天</option>          <option value="week">一周</option>      </select>  </div>  <!-- 多選結果選項的下拉框 --><div data-role="fieldcontain">      <label for="select-choice-2" class="select">多項挑選清單</label>      <select data-native-menu="false" multiple="multiple" name="select-choice-2" id="select-choice-2">          <option value="12h">12小時</option>          <option value="1d">一天</option>          <option value="2d">兩天</option>          <option value="week">一周</option>      </select>  </div>  <!-- 分組單選結果選項的下拉框 --><div data-role="fieldcontain">      <label for="select-choice-3" class="select">分組挑選清單</label>      <select data-native-menu="false" name="select-choice-3" id="select-choice-3">          <optgroup label="Group1">              <option value="12h">12小時</option>              <option value="1d">一天</option>              <option value="2d">兩天</option>              <option value="week">一周</option>          </optgroup>          <optgroup label="Group2">              <option value="1m">一個月</option>              <option value="1q">一季度</option>              <option value="1y">一年</option>          </optgroup>      </select>  </div>  <div data-role="fieldcontain">      <label for="text">文本輸入框</label>      <input type="text" name="text" id="text" value=""  />  </div>  <div data-role="fieldcontain">      <label for="text">文本輸入框</label>      <input type="text" name="text" id="text" value=""  />  </div>  <div data-role="fieldcontain">      <label for="textarea">文本輸入欄位</label>      <textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>  </div>  <div data-role="fieldcontain">      <label for="search">搜尋輸入框</label>      <input type="search" name="search" id="search" value="" />  </div>        <fieldset>  <div><button type="submit" data-theme="c">Cancel</button></div>  <div><button type="submit" data-theme="b">Submit</button></div> </fieldset>    </div>   <div data-role="footer" data-theme="a" data-position="fixed">   <h2>a頁面的底部</h2>   </div>   </div></body></html>

jQuery mobile 學習12 表單的使用方法及訪問裝置判斷

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.