jQuery prependTo function not working as expected
Hello Everyone:
I am doing an exercise using prependTo function. instead of appending before the paragraph in the HTML body. The text appeared on a separate line.
Could you explain to me how appendTo and prependTo works, so I understood its behavior. Thanks!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html>
- <head>
- <title>hello world</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="stylesheet" href="stylesheet1.css" type="text/css" />
-
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" ></script>
- <script language="JavaScript" type="text/javascript">
-
- <!--
- $(document).ready(function(){
- var p1= $('<p>use preappend to add some text</p>').prependTo('#disclaimer');;
-
- //$('p1').prependTo('#disclaimer'); //doesn't work as expected append the text before paragraphy with id = disclaimer
- });
- //-->
- </script>
- </head>
- <body>
- <p id="disclaimer">this is a legal statement of our website</p>
- </body>
- </html>