解決方案:
<html>
<head>
<!-- STYLESHEETS //-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<!-- JavaScripts //-->
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.list1').replaceWith('<a class="list3" href="#">link3</a>');
});
</script>
</head>
<body>
<h1> hello world </h1>
<div class="content-page" >
<div class="list-page">
<a class="list1" href="#">link1</a>
<a class="list2" href="#">link2</a>
</div>
</div>
</body>
你需要用你的代碼文件準備好。
或者,如果你想jQuery Mobile的版本:
<html>
<head>
<!-- STYLESHEETS //-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<!-- JavaScripts //-->
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
$(document).on('pagebeforeshow', '.content-page', function() {
$('.list1').replaceWith('<a class="list3" href="#">link3</a>');
});
</script>
</head>
<body>
<h1> hello world </h1>
<div class="content-page" data-role="page">
<div class="list-page">
<a class="list1" href="#">link1</a>
<a class="list2" href="#">link2</a>
</div>
</div>
</body>
編輯:
在你的榜樣,更換這些線路:
<script type="text/javascript"src="jquery.mobile-1.3.0"></script>
<link rel="stylesheet" href="jquery.mobile-1.3.0" type="text/css">
<script type="text/javascript" src="jquery.js"></script>
有了這個線:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<!-- JavaScripts //-->
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"</script>
基本上先初始化jQuery Mobile css,然後初始化jQuery然後初始化jQuery Mobile。在你的例子中,你正在jQuery Mobile之前初始化jQuery Mobile,可能會導致錯誤。
當我用你的jquery語句它沒有工作。但是當我複製你的整個代碼它的工作。我在這裏錯過了什麼? :( – crowso 2013-04-08 16:24:11
你是在說我的第一個還是第二個例子? – Gajotres 2013-04-08 16:45:44
當我用你的代替我的jquery代碼行時,它不起作用,請幫助我。 – crowso 2013-04-08 16:47:17