这个例子来自一本书。它告诉我,如果我将 clone() 中的参数设置为 false,我可以克隆没有文本的段落。我查看了 jQuery 中的文档,并尝试了所有真假组合。结果证明我不能复制没有文字的段落。它只是jQuery中的一个错误吗?
<html>
<head>
<title>Copying element</title>
<script src="../jquery-1.8.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
//copy elment and insert
$('div.chapter p:eq(0)').clone(false).insertBefore('div.chapter');
});
</script>
<style type="text/css">
span.footnote{
font-style:italic;
display:block;
}
.chapter span.footnote{
display:inline;
}
.chapter p{
width:50%;
}
</style>
</head>
<body>
<h1 id="f-title">Flatland: A ROmance of Many Dimension</h1>
<div id="f-author">by Edwin A. Abbott</div>
<h2>Part 1, Section 3</h2>
<h3 id="f-subtitle">Concerning the Inhabitants of Flatland</h3>
<div id="excerpt">an excerpt</div>
<div class="chapter">
<p class="squre">Our professional Men and Gentlemen are Squares (to which class I myself belong) and FIve-Sided Figures
or Pentagons.
</p>
<p class="mobility hexagon">Next above these come the Nobility of whoem there are serverl degress
<a href="http://en.wikipedia.org/wiki/Hexagon">Hexagons</a>and from thence rising in the number of theirside till they received the honourable title of
<a href="http://en.wikipedia.org/wiki/Polygon">Polygonal</a>
</p>
<p><span class="pull-quote">It is a <span class="drop">Law of Nature</span>with us that a mable child shall have </span>
</p>
<p>But this rule applies not always to the Tradesman</p>
<p>Rarely -- in proportion to the vast numbers of Isosceles
</p>
<p>The birth of tha Ture Equlaterial Traignel from Isoscele parents is the subject of rejociing in the coutry for many furlongs.
</p>
<p>How admirable is the Law of Compensation!
</p>
</div>
</body>
</html>