Hello,
I am reading Learning jQuery 3rd Edition by Chaffer, I have completed chapter 5 and working on the chapter 5 questions. I have completed all the questions except one question#2.
Can anyone help me figure out how to achieve the following task?
"2.) When a back to top link is clicked, add a new paragraph after the link,
containing the message You were here. Ensure that the link still works."
Thanks, JB
jQuery code:
HTML code:Code:$(function(){ $('<a id="top"></a>').prependTo('body'); $('<a href="#top">back to top</a>').insertAfter('div.chapter p') var $clonedCopy = $(this).clone(); $clonedCopy .insertAfter('<a href="#top">back to top</a>') .find('#top') .text('You were here') .end(); });
Code:<body> <div id="container"> <h1 id="f-title">Flatland: A Romance of Many Dimensions</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="square">Our Professional Men and Gentlemen are Squares (to which class I myself belong) and Five-Sided Figures or <a href="http://en.wikipedia.org/wiki/Pentagon">Pentagons</a>.</p> <p class="nobility hexagon">Next above these come the Nobility, of whom there are several degrees, beginning at Six-Sided Figures, or <a href="http://en.wikipedia.org/wiki/Hexagon">Hexagons</a>, and from thence rising in the number of their sides till they receive the honourable title of <a href="http://en.wikipedia.org/wiki/Polygon">Polygonal</a>.</p> <p><span class="pull-quote">It is a Law of Nature <span class="drop">with us</span> that a male child shall have <strong>one more side</strong> than his father</span>, so that each generation shall rise (as a rule) one step in the scale of development and nobility. Thus the son of a Square is a Pentagon; the son of a Pentagon, a Hexagon; and so on.</p> </body></html>


Reply With Quote

Bookmarks