问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何利用jQuery Mobile设计出按钮并触发事件

发布网友 发布时间:2022-05-12 04:23

我来回答

2个回答

懂视网 时间:2022-05-12 08:44

一、链接按钮


<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web 应用程序</title>
<link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head> 
<body>
<p data-role="page" id="page1" data-fullscreen="true">
 <p data-role="content">
 	<a href="#" data-role="button">链接按钮</a>
 </p>
</p>
</body>
</html>

二、表单按钮


<p data-role="page" id="page1" data-fullscreen="true">
 <p data-role="content">
 	<a href="#" data-role="button">链接按钮</a>
 <form>
 	<input type="button" value="表单按钮"/>
  <button type="submit">提交按钮</button>
  <input type="submit" value="提交按钮"/>
  <input type="reset" value="重置按钮"/>
 </form>
 </p>
</p>

三、图形按钮


  图像按钮1:
  <input type="image" src="jquery-mobile/images/icon.png" data-role="none"/>
  图像按钮2:
  <a href="#"><img src="jquery-mobile/images/icon.png"></a>

四、带图标的按钮


  <input type="button" value="带图标的按钮" data-icon="delete"/>
 	 <input type="button" data-icon="delete" data-iconpos="notext"/>
 	 <input type="button" data-icon="alert" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-d" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-l" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-r" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-u" data-iconpos="notext"/>
  <input type="button" data-icon="back" data-iconpos="notext"/>
  <input type="button" data-icon="check" data-iconpos="notext"/>
  <input type="button" data-icon="custom" data-iconpos="notext"/>
  <input type="button" data-icon="forward" data-iconpos="notext"/>
  <input type="button" data-icon="gear" data-iconpos="notext"/>
  <input type="button" data-icon="grid" data-iconpos="notext"/>
  <input type="button" data-icon="home" data-iconpos="notext"/>
  <input type="button" data-icon="info" data-iconpos="notext"/>
  <input type="button" data-icon="minus" data-iconpos="notext"/>
  <input type="button" data-icon="plus" data-iconpos="notext"/>
  <input type="button" data-icon="refresh" data-iconpos="notext"/>
  <input type="button" data-icon="search" data-iconpos="notext"/>
  <input type="button" data-icon="star" data-iconpos="notext"/>


五、按钮定位


  <a href="#" data-role="button" data-icon="arrow-u" data-iconpos="top">top</a>
  <a href="#" data-role="button" data-icon="arrow-l" data-iconpos="left">left</a>
  <a href="#" data-role="button" data-icon="arrow-r" data-iconpos="right">right</a>
  <a href="#" data-role="button" data-icon="arrow-d" data-iconpos="bottom">bottom</a>

六、自定义图标按钮


<a href="#" data-role="button" data-icon="custom_icon">自定义图标</a>
.ui-icon-custom_icon{
	background:url(jquery-mobile/images/icon.png) 50% 50% no-repeat;
	background-size:14px 14px;
}

注意:属性命名规则“.ui-icon-<data-icon-value>,如上面的.ui-icon-custom_icon



七、分组按钮


 <p data-role="controlgroup" data-type="horizontal" align="center" class="segment-control">
  <a href="#" data-role="button" class="ui-control-active">菜单一</a>
  <a href="#" data-role="button" class="ui-control-inactive">菜单二</a>
  <a href="#" data-role="button" class="ui-control-inactive">菜单三</a>
 </p>

八、主题按钮


  <a href="#" data-role="button" data-theme="a">A</a>
  <a href="#" data-role="button" data-theme="b">B</a>
  <a href="#" data-role="button" data-theme="c">C</a>
  <a href="#" data-role="button" data-theme="d">D</a>
  <a href="#" data-role="button" data-theme="e">E</a>
  <a href="#" data-role="button" data-theme="f">F</a>


九、动态按钮


<script type="text/javascript">
	$('<a href="#" data-role="button" data-icon="star" id="b1">动态按钮</a>').appendTo("#content").button();
	$('<a href="#" data-role="button" data-icon="delete" id="b2">动态按钮</a>').insertAfter("#b1").button();
</script>

还有一种json方式的


	$('<a href="#">动态按钮</a>').insertAfter("#a1").button({
			'icon':'home',
			'inline':true,
			'shadow':true,
			'theme':'b'
		});

上面两种方式都用到了button()插件,button插件具有如下选项:

corners boolean

icon string

iconpos string

iconshadow boolean

initSelector css selector string

inline boolean

shadow boolean

button插件有如下两个方法:

$("#button1").button("enable");

$("#button2").button("disable");

全部代码如下:


<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web 应用程序</title>
<link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<style type="text/css">
.ui-icon-custom_icon{
	background:url(jquery-mobile/images/icon.png) 50% 50% no-repeat;
	background-size:14px 14px;
}
</style>
</head> 
<body>
<p data-role="page" id="page1" data-fullscreen="true">
 <p data-role="content" class="content" id="content">
 	<a href="#" data-role="button">链接按钮</a>
 <form>
 	<input type="button" value="表单按钮"/>
  <button type="submit">提交按钮</button>
  <input type="submit" value="提交按钮"/>
  <input type="reset" value="重置按钮"/>
  图像按钮1:
  <input type="image" src="jquery-mobile/images/icon.png" data-role="none"/>
  图像按钮2:
  <a href="#"><img src="jquery-mobile/images/icon.png"></a>
			
  <input type="button" value="带图标的按钮" data-icon="delete"/>
 			<input type="button" data-icon="delete" data-iconpos="notext"/>
 			<input type="button" data-icon="alert" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-d" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-l" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-r" data-iconpos="notext"/>
  <input type="button" data-icon="arrow-u" data-iconpos="notext"/>
  <input type="button" data-icon="back" data-iconpos="notext"/>
  <input type="button" data-icon="check" data-iconpos="notext"/>
  <input type="button" data-icon="custom" data-iconpos="notext"/>
  <input type="button" data-icon="forward" data-iconpos="notext"/>
  <input type="button" data-icon="gear" data-iconpos="notext"/>
  <input type="button" data-icon="grid" data-iconpos="notext"/>
  <input type="button" data-icon="home" data-iconpos="notext"/>
  <input type="button" data-icon="info" data-iconpos="notext"/>
  <input type="button" data-icon="minus" data-iconpos="notext"/>
  <input type="button" data-icon="plus" data-iconpos="notext"/>
  <input type="button" data-icon="refresh" data-iconpos="notext"/>
  <input type="button" data-icon="search" data-iconpos="notext"/>
  <input type="button" data-icon="star" data-iconpos="notext"/>
  
  <a href="#" data-role="button" data-icon="arrow-u" data-iconpos="top">top</a>
  <a href="#" data-role="button" data-icon="arrow-l" data-iconpos="left">left</a>
  <a href="#" data-role="button" data-icon="arrow-r" data-iconpos="right">right</a>
  <a href="#" data-role="button" data-icon="arrow-d" data-iconpos="bottom">bottom</a>
  
  <a href="#" data-role="button" data-icon="custom_icon">自定义图标</a>
  
  <a href="#" data-role="button" data-theme="a">A</a>
  <a href="#" data-role="button" data-theme="b">B</a>
  <a href="#" data-role="button" data-theme="c">C</a>
  <a href="#" data-role="button" data-theme="d">D</a>
  <a href="#" data-role="button" data-theme="e" id="a1">E</a>
  <a href="#" data-role="button" data-theme="f" id="b1">F</a>
 </form>
 </p>
</p>
</body>
<script type="text/javascript">
	$('<a href="#" data-role="button" data-icon="star" id="b1">动态按钮</a>').appendTo("#content").button();
	$('<a href="#" data-role="button" data-icon="delete" id="b2">动态按钮</a>').insertAfter("#b1").button();
	$('<a href="#">动态按钮</a>').insertAfter("#a1").button({
			'icon':'home',
			'inline':true,
			'shadow':true,
			'theme':'b'
		});
</script>
</html>

热心网友 时间:2022-05-12 05:52

首先,需要到官网上下载jQuery Mobile,然后将其复制拷贝到项目的目录下。

接着,在项目中的pages目录下,新建一个HTML5页面,取名为“button.html"。

利用jQuery Mobile,需要将其核心的js和css样式文件拷贝到相应的目录下。

接着,在<body></body>中插入<a href="#" class="ui-btn">查询</a>。

然后,将项目部署到Tomcat下,启动Tomcat,在浏览器上查看页面。

最后,将地址拷贝到谷歌浏览器上,利用手机模拟器查看页面。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
瑞安皇都大厦几个电梯 办签证和护照的具体步骤和一共的费用!我需要详细一点的答案. 办护照流程 办护照的流程是什么 哪位推荐几部韩剧啊!!要像豪杰春香,魔女幼熙这样的,剧情要感人,最好是... 小阴唇内应该是光滑的吗,阴道口痒为什么 阴道口有像草莓样正常吗 任氏族谱字辈:世秉忠贞 永达明玉起 国正天元律迎祖大继昌 河南夏氏家谱辈分我是永城市酂城镇夏氏夏世界具家谱记载洪武二年始祖良... 夏侯姓字辈排行 夏氏辈行,我爷爷明字辈,我父亲应字辈,我是崇字辈,后面是什么辈? 35岁程序员怎么转行 新西兰打工是个骗局吗? 新西兰留学 打工问题! 跪求一份寒假社会实践报告.... 题目是 关注民生,关注生态——社会调研活动 字数在 2000~ 2500字左右 我想去新西兰工作,农场工,我英语不好,不知道能过去不?你能给我推荐其他国家的工作吗?费用多少,具体 虎年姓刘女孩起名字 新西兰出国打工到底哪个劳务派遣公司靠谱 《两史三情》(党史,国史,国情,省情,市情)社会调查报告 新西兰打工 我的ps水平很一般,但是我想做一个地图板块的立体的,就想图片中的一样?具体该怎么操作呢? 给姓刘虎年出生的女孩取名 本人急求一篇社会问题调查报告?!800字左右 ps怎么画地图类型的图,向下面这样 垃圾焚烧厂烟气怎么降温 兔宝宝取名字(乳名+全名),有嘉奖哟~~~ 世界上第一台计算机是如何诞生的? 利用火山焚烧垃圾,一天就能处理70亿吨,科学家为何不愿尝试? 国外有的垃圾焚烧厂烟气处理采用酸性吸收液和碱性吸收液分开洗涤,酸性吸收液的目的是去除什么有害物质? 怀孕快三个月吃了点酸菜会不会有影响 手表进水不走了能修好不 先生是什么生肖 “先生”猜一种动物? 十二生肖谁是先生 老先生,猜一生肖 风水师 算命先生一般指什么生肖 大笔先生,十二生肖,代表什么 算命先生代表什么动物 脑筋急转弯:欲钱买算命先生的动物。是比喻什么生肖? 人人尊它翁先生是什么生肖 脚趾甲大的脚趾变厚变白变空,其他变白变厚 大脚趾脚指甲有一点空了 哪位大神可以帮忙给宝宝起个名字,刘姓,女孩,阳光一点的四个字三个字都可以!非常感谢&#128591; 请帮我起一个阳光一点的名字,女孩,10月27日出生。姓郭 大脚趾 侧面指甲空了一小部分。 医生你好,我2个大脚趾一到冬天就空半个指甲,夏天就慢慢好转。这是怎么回事啊, 药师考编需要党员吗 我的脚指甲前段时间变黑了,现在有一块好像空了~怎么回事啊 大脚趾淤血导致指甲空了怎么处理? 大脚趾指甲空了一半,里面挖出来都是粉末状的东西 怎么回事? 事业编考试条件需要党员吗