This is the first paragraph.
Try the code out and play with it on jsFiddle.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://peter-ajtai.com/jquery/jquery-1.4.2.min.js"></script> </head> <body> <div id="container"> <input type="button" value="Click to toggle" /><br/> <p>This is the first paragraph.</p> </div> <script type="text/javascript"> $('input').toggle( function () { var content = '<p id="box">' + 'This is the second paragraph' + '</p>'; $("#container").append(content); }, function () { $('#box').remove(); } ); </script> <br/><br/><br/> <h2>The Code (fresh off the presses, displaying what was used above):</h2> <p style="color:green; font-family:sans-serif;"> Try the code out and play with it on <a href="http://jsfiddle.net/mjUcR/">jsFiddle</a>.</p> <?php include_once "../php/codify-function.php"; // Show code ################################################################## codify(file_get_contents(__FILE__), 'javascript'); ?> </body> </html>