Dave's Brain

Browse - Programming Tips - What's the different between append() and after()

Date: 2013oct1
Library: jquery
Language: javaScript

Q.  What's the different between append() and after()

A.  append() puts more stuff *inside* the selected node at the end.
after() puts more stuff following the selected node -- not inside it.
For example:

<span id=hello>Hello</span> <script> $('#hello').append(' World'); alert($('#hello')); // Will say "Hello World" // Puts the byte span after the hello span $('#hello').after('<span id=bye>Bye</span>'); alert($('#bye')); // Will say "Bye" </script>

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.