有关jQuery Mobile中的按钮操作

在 jQuery Mobile 中创建按钮

jQuery Mobile中的按钮可通过三种方法创建:

  • 使用 < button > 元素            < button >按钮< /button >
  • 使用 < input > 元素              < input type=“button” value=“按钮” >
  • 使用 data-role=“button” 的 < a > 元素    < a href="#" data-role=“button”>按钮< /a >

提示:jQuery Mobile 中的按钮会自动获得样式,这增强了他们在移动设备上的交互性和可用性。推荐您使用 data-role=“button” 的 < a > 元素来创建页面之间的链接,而 < input > 或 < button > 元素用于表单提交。

行内按钮

默认情况下,按钮会占据屏幕的全部宽度。如果您需要按钮适应其内容,或者如果您需要两个或多个按钮并排显示,请添加 data-inline=“true”

<a href="#pagetwo" data-role="button" data-inline="true">转到页面二</a>
组合按钮

jQuery Mobile 提供了对按钮进行组合的简单方法。

请将 data-role=“controlgroup” 属性与 data-type=“horizontal|vertical” 一同使用,以规定水平或垂直地组合按钮:

<div data-role="controlgroup" data-type="horizontal">
  <a href="#anylink" data-role="button">按钮 1</a>
  <a href="#anylink" data-role="button">按钮 2</a>
  <a href="#anylink" data-role="button">按钮 3</a>
</div>
后退按钮

如需创建后退按钮,请使用 data-rel=“back” 属性(会忽略锚的 href 值):

<a href="#" data-role="button" data-rel="back">返回</a>
更多用于按钮的 data-* 属性
属性描述
data-cornerstrue /false规定按钮是否有圆角
data-minitrue /false规定是否是小型按钮
data-shadowtrue /false规定按钮是否有阴影
为 jQuery Mobile 按钮添加图标

如需向您的按钮添加图标,请使用 data-icon 属性:

<a href="#anylink" data-role="button" data-icon="search">搜索</a>
定位图标

您也能够规定图标被放置的位置:上、右、下或左。
请使用 data-iconpos 属性来规定位置:
图标位置:

<a href="#link" data-role="button" data-icon="search" data-iconpos="top"></a>
<a href="#link" data-role="button" data-icon="search" data-iconpos="right"></a>
<a href="#link" data-role="button" data-icon="search" data-iconpos="bottom"></a>
<a href="#link" data-role="button" data-icon="search" data-iconpos="left"></a>
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值