<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jquerylib/jquery-1.12.3.js"></script>
<script>
//设置内容的回调函数
// $(document).ready(function(){
// $("#btn1").click(function(){
// $("#test1").html(function(i,text){
// return("the old text:"+text+" "+"the new text:hello world!(index:"+i+")");
// });
// });
// $("#btn2").click(function(){
// $("#test2").html(function(i,html){
// return("the old text:"+html+" "+"the new text:hello <b>world!</b>(index:"+i+")");
// });
// });
// });
//设置属性的回调函数
$(document).ready(function(){
$("button").click(function(){
$("#w3c").attr("href",function(i,value){
return "http://www.baidu.com";
});
});
});
</script>
</head>
<body>
<!--<p id="test1">这是<b>粗体</b>文本。</p>
<p id="test2">这是另一段<b>粗体</b>文本。</p>
<button id="btn1">显示旧/新文本</button>
<button id="btn2">显示旧/新 HTML</button>-->
<p><a href="http://www.w3school.com.cn" id="w3c">W3School.com.cn</a></p>
<button>改变 href 值</button>
<p>请把鼠标指针移动到链接上,或者点击该链接,来查看已经改变的 href 值。</p>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jquerylib/jquery-1.12.3.js"></script>
<script>
//设置内容的回调函数
// $(document).ready(function(){
// $("#btn1").click(function(){
// $("#test1").html(function(i,text){
// return("the old text:"+text+" "+"the new text:hello world!(index:"+i+")");
// });
// });
// $("#btn2").click(function(){
// $("#test2").html(function(i,html){
// return("the old text:"+html+" "+"the new text:hello <b>world!</b>(index:"+i+")");
// });
// });
// });
//设置属性的回调函数
$(document).ready(function(){
$("button").click(function(){
$("#w3c").attr("href",function(i,value){
return "http://www.baidu.com";
});
});
});
</script>
</head>
<body>
<!--<p id="test1">这是<b>粗体</b>文本。</p>
<p id="test2">这是另一段<b>粗体</b>文本。</p>
<button id="btn1">显示旧/新文本</button>
<button id="btn2">显示旧/新 HTML</button>-->
<p><a href="http://www.w3school.com.cn" id="w3c">W3School.com.cn</a></p>
<button>改变 href 值</button>
<p>请把鼠标指针移动到链接上,或者点击该链接,来查看已经改变的 href 值。</p>
</body>
</html>