JQ 替换节点

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(function(){
	$("p").replaceWith("<strong>你最不喜欢的水果是?</strong>"); 
	// 同样的实现: $("<strong>你最不喜欢的水果是?</strong>").replaceAll("p"); 
});
//]]>
</script>
</head>
<body>
<p title="选择你最喜欢的水果." >你最喜欢的水果是?</p>
<ul>
<li title='苹果'>苹果</li>
<li title='橘子'>橘子</li>
<li title='菠萝'>菠萝</li>
</ul>
</body>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2290868
jq