zl程序教程

您现在的位置是:首页 >  工具

当前栏目

jqueryMoblie入门—helloworld的示例代码学习

学习入门代码 示例 HelloWorld
2023-06-13 09:14:43 时间
1、需要运行JQueryMobile移动应用页面,需要下载JQueryMobile3个相关插件文件(有多版本),jquery.mobile-1.2.0.min.css、jquery-1.8.3.min.js、jquery.mobile-1.2.0.min.js,JQueryMobile官网地址:http://jquerymobile.com
2、将插件文件加载到页面中,注意它们的加载顺序,语句如
复制代码代码如下:

<linkhref="Css/jquery.mobile-1.2.0.min.css"rel="Stylesheet"type="text/css"/>
<scriptsrc="Js/jquery-1.8.3.min.js"type"text/javascript"></script>
<scriptsrc="Js/jquery.mobile-1.2.0.min.js"type="text/javascript"></script>

3、HelloWorld的示例代码如下
复制代码代码如下:

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<TITLE>NewDocument</TITLE>
<metaname="viewport"content="width=device-width,initial-scale=1"/>//设置页面的宽度与移动设备的屏幕宽度相同
<linkhref="Css/jquery.mobile-1.2.0.min.css"rel="Stylesheet"type="text/css"/>
<scriptsrc="Js/jquery-1.8.3.min.js"type"text/javascript"></script>
<scriptsrc="Js/jquery.mobile-1.2.0.min.js"type="text/javascript"></script>
</HEAD>
<BODY>
<divid="page1"data-role="page">
<divdata-role="header"><h1>JQueryMoblie</h1></div>
<divdata-role="content"class="content"><p>HelloWorld!</p></div>
<divdata-role="footer"><h1>工作室版权所有</h1></div>
</div>
</BODY>
</HTML>

4、由于JQueryMobile已经全面支持HTML5结构,因此,<body>主体元素代码也可以修改为:
复制代码代码如下:
<BODY>
<sectionid="page1"data-role="page">
<headerdata-role="header"><h1>JQueryMoblie</h1></header>
<divdata-role="content"class="content"><p>HelloWorld!</p></div>
<footerdata-role="footer"><h1>工作室版权所有</h1></footer>
</section>
</BODY>

5、为了更好地在PC端浏览JQueryMobile页面在移动终端的执行效果,可以下载Opera移动模拟器,下载地址:http://cn.opera.com/,预览效果图: