Using clone to replace text instead of appending
I'm trying to replace the text inside each <h1> in the Articles with the matching link from the Aside. I am able to get the link there, but cannot get rid of the original text.
- <html>
<head>
<title>Link Copy</title>
<script type="text/javascript" src="../jquery-1.9.1.js"></script>
<script type="text/javascript">
$("document").ready(function() {
// Copy link from aside to articles
$("aside section hgroup a").each(function() {
// Find matching Article heading
$(this).clone().appendTo("article h1:contains('" + $(this).text() + "')");
});
});
</script>
</head>
<body>
<header id="header">
<hgroup>
<h1>Main Title</h1>
<h2>Main Subtitle</h2>
</hgroup>
</header>
<article>
<h1>Article 1</h1>
</article>
<aside class="aside">
<header>
<h1> Health & Nutrition </h1>
<p> Are you where you want to be? </p>
</header>
<p> It's all about making the choices that will give us the results we desire. </p>
<section>
<hgroup>
<h1><a href="../article1.php">Article 1</a></h1>
</hgroup>
<p>
This includes not only food, but what we breath and put on our bodies
as well. It even involves what we think!
</p>
</section>
<section>
<hgroup>
<h1><a href="../article2.php">Article 2</a></h1>
</hgroup>
<p>
When we are not able get everything our body needs, high-quality
supplements can fill the gap.
</p>
</section>
<section>
<hgroup>
<h1><a href="../article3.php">Article 3</a></h1>
</hgroup>
<p>
Exercise is necessary for our bodies to be in shape.
</p>
</section>
</aside>
<article>
<h1>Article 2</h1>
</article>
<article>
<h1>Article 3</h1>
</article>
</body>
</html>
Thanks,
Brent