この例は本からのものです。clone() のパラメーターを false に設定すると、テキストなしで段落を複製できることがわかります。jQuery のドキュメントをチェックアウトし、true と false のすべての組み合わせを試しました。結果は、テキストなしで段落をコピーできないことを証明しました. 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>