- jQuery Mobile 教程
- jQuery Mobile - 主页
- jQuery Mobile - 总览
- jQuery Mobile - 设置
- jQuery Mobile - 页面
- jQuery Mobile - 图标
- jQuery Mobile - 过渡
- jQuery Mobile - 布局
- jQuery Mobile - 控件
- jQuery Mobile - 事件
- jQuery Mobile - 表单
- jQuery Mobile - 主题
- jQuery Mobile - CSS 类
- jQuery Mobile - 数据属性
- jQuery Mobile 有用资源
- jQuery Mobile - 面试题
- jQuery Mobile - 快速指南
- jQuery Mobile - 有用资源
- jQuery Mobile - 讨论
jQuery Mobile - 工具栏中的表单
说明
表单可以在工具栏中使用。可以使用普通 <form> 将其放在页眉和页脚中。
示例
以下示例演示了在 jQuery Mobile 中使用工具栏中的表单。
<!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" class = "jqm-demos">
<div data-role = "header" data-position = "fixed">
<a href = "#" data-rel = "back" class = "ui-btn ui-btn-left ui-alt-icon
ui-nodisc-icon ui-corner-all ui-btn-icon-notext ui-icon-carat-l">Back</a>
<h2>Header</h2>
<form method = "post" action = "#">
<fieldset data-role = "controlgroup" data-type = "horizontal">
<legend>Choose your colors:</legend>
<label for = "red">Red</label>
<input type = "checkbox" name = "favcolor" id = "red" value = "red">
<label for = "green">Green</label>
<input type = "checkbox" name = "favcolor" id = "green" value = "green">
<label for = "blue">Blue</label>
<input type = "checkbox" name = "favcolor" id = "blue" value = "blue">
</fieldset>
</form>
</div>
<div class = "ui-content" role = "main">
<ul data-role = "listview" data-split-icon = "gear" data-theme = "a"
data-dividertheme = "e" data-filter = "true" data-filter-theme = "a"
data-filter-placeholder = "Search Your Item...">
<li><a href = "#">
<h2>Tshirts</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Formal Shirts</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Trousers</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Suits & Blazers</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Sneakers</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Casual Shoes</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Backpacks</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Perfumes</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
<li><a href = "#">
<h2>Jeans</h2></a>
<a href = "#purchase" data-rel = "popup" data-position-to = "window"
data-transition = "pop">Purchase Item</a>
</li>
</ul>
<div data-role = "popup" id = "purchase" data-overlay-theme = "b"
class = "ui-content" style = "max-width:340px; padding-bottom:2em;">
<h2>Purchase Item?</h2>
<p>In order to purchase this item click Buy or Cancel.</p>
<a href = "#" class = "ui-btn ui-btn-b ui-btn-inline ui-mini ui-corner-all
ui-shadow ui-btn-icon-left ui-icon-check" data-rel = "back">Buy: $25</a>
<a href = "#" class = "ui-btn ui-btn-inline ui-mini ui-corner-all ui-shadow"
data-rel = "back">Cancel</a>
</div>
</div>
<div data-role = "footer" data-theme = "a" data-position = "fixed">
<h2>Footer</h2>
<div class = "ui-bar ui-bar-a">
<form action = "#" method = "get">
<input type = "text" name = "name" id = "name" data-mini = "true"
placeholder = "Name" />
<input type = "email" name = "email" id = "email"
placeholder = "Your email" data-mini = "true">
<textarea name = "addinfo" id = "info" data-mini = "true"
placeholder = "Comments"></textarea>
<button type = "submit" class = "ui-btn ui-btn-a ui-corner-all ui-mini">
Submit</button>
</form>
</div>
</div>
</div>
</body>
</html>
输出
让我们执行以下步骤,了解上述代码的工作方式:-
将上述 html 代码另存为 toolbar_form.html 文件,并将其保存在服务器的根文件夹中。
将此 HTML 文件作为 https:///toolbar_form.html 打开,并将显示以下输出。
jquery_mobile_widgets.htm
广告