如果我使用本地 jquery.js 文件,我的问题非常类似于jQuery 代码不起作用,为什么?.
但是,那里给出的解决方案对我不起作用。
我创建了一个带有UTF-8
编码的文件,但它仍然无法正确呈现。
使用外部jQuery
文件虽然有效。
这是我的 MWE:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<link href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css" rel="stylesheet">
<link href="http://code.jquery.com/mobile/1.2.0/css/jquery.mobile.structure-1.2.0.min.css" rel="stylesheet">
<script charset="utf-8" src="js/cordova-2.2.0.js" type="text/javascript"></script>
<script charset="utf-8" src="js/index.js" type="text/javascript"></script>
<script charset="utf-8" src="js/jquery-1.9.0.min.js" type=
"text/javascript"></script>
<script charset="utf-8" src="js/jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('div.ui-page').live("swipeleft", function() {
var nextpage = $(this).next('div[data-role="page"]');
if (nextpage.length > 0) {
$.mobile.changePage(nextpage, {
transition: "slide",
reverse: false
});
}
});
$('div.ui-page').live("swiperight", function() {
var prevpage = $(this).prev('div[data-role="page"]');
if (prevpage.length > 0) {
$.mobile.changePage(prevpage, {
transition: "slide",
reverse: true
});
}
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h2 class="ui-title"><strong>Page one</strong></h2>
</div>
<div data-role="content">
<strong>You are in page one.</strong>
</div>
<div data-id="foo1" data-position="fixed" data-role="footer">
<div data-role="navbar">
<ul>
<li><strong><a data-icon="home" href=
"index.html">Home</a></strong></li>
<li><strong><a data-icon="info" href=
"b.html">Info</a></strong></li>
<li><strong><a data-icon="gear" href=
"#">Settings</a></strong></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
</div>
<div data-role="page">
<div data-role="header">
<h2 class="ui-title"><strong>Page two</strong></h2>
</div>
<div data-role="content">
<strong>You are in page two.</strong>
</div>
<div data-id="foo1" data-position="fixed" data-role="footer">
<div data-role="navbar">
<ul>
<li><strong><a data-icon="home" href=
"index.html">Home</a></strong></li>
<li><strong><a data-icon="info" href=
"b.html">Info</a></strong></li>
<li><strong><a data-icon="gear" href=
"#">Settings</a></strong></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
</div>
</body>
</html>