我正在使用Jquery mobile 1.4.1。我试图显示一个jquery移动列表视图,但在使用Jquery插入代码时它无法正确显示。问题是jquery不插入css类。这是我的代码和屏幕截图:
<!DOCTYPE html>
<html>
<head>
<title>Web service</title>
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.1.css">
<link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.4.1.css">
<link rel="stylesheet" type="text/css" href="css/jquery.mobile.theme-1.4.1.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/jquery.mobile-1.4.1.min.js"></script>
<script>
$(document).ready(function() {
$.getJSON("http://localhost/WebService/web-service.php?format=json", function(result) {
var html = "";
$.each(result.posts, function(i, field) {
html = html.concat("<li><a href='#'>" + field.post.fullname + "</a></li>");
});
document.getElementById('list').innerHTML = html;
});
});
</script>
</head>
<body>
<!-- Start of first page -->
<div data-role="page" id="foo">
<div data-role="header">
<h1>Foo</h1>
</div><!-- /header -->
<div role="main" class="ui-content">
<p>I'm first in the source order so I'm shown as the page.</p>
<p>View internal page called <a href="#bar">bar</a></p>
<ul data-role="listview" id="list"></ul>
</div>
<!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
<!-- Start of second page -->
<div data-role="page" id="bar">
<div data-role="header">
<h1>Bar</h1>
</div><!-- /header -->
<div role="main" class="ui-content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my id is beeing clicked.</p>
<p><a href="#foo">Back to foo</a></p>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>
我该如何解决?
答案 0 :(得分:0)
你想以listview的形式展示什么?他们是这三个项目吗? 1.bar 2.taieb baccouch 3.zahra daqrir 比以下代码可以帮助你..
<div>
<ul data-role="listview" class="jqm-list">
<li><a><span>bar</span></a></li>
<li><a><span>taieb baccouch </span></a></li>
<li><a><span>zahra daqrir</span></li>
</ul></div>