解决方案:
<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