<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<title></title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<link href="jquery-ui/css/base/jquery-ui-1.9.2.custom.css" rel="stylesheet">
<script src="jquery-ui/js/jquery-1.8.3.js"></script>
<script src="jquery-ui/js/jquery-ui-1.9.2.custom.js"></script>
<style type="text/css">
</style>
</head>
<body>
<center>
<input type="button" id="btn" value="包装"/>
<div id="div1">
<p>jquery</p>
<p>百度是一家公司</p>
<p>360 这里也有一个百度</p>
</div>
</center>
<script type="text/javascript">
$(function(){
$("#btn").click(function(){
if($("p:contains('百度')").length>0){
var a=$("p:contains('百度')")[0];
var txt=$(a).text();
var txt2=txt.replace('百度',"<a href='http://www.baidu.com'>百度</a>");
$(a).html(txt2);
}
});
})
</script>
</body>
</html>