Web Development with jQuery®

(Elliott) #1

Manipulating HTML and Text Content (^) ❘ 113
methods, as you did with the before() and after() methods, you use a selector to reference another
element in your document that you want inserted beside another element. In addition, the logic is
reversed in how you write the script that does the insert beside action. The following document,
which can be found as Example 4-8 in the source materials, demonstrates how you might use the
insertBefore() and insertAfter() methods:
<!DOCTYPE HTML>






John Lennon and Paul McCartney Albums




















Title Year
Title Year


John Lennon ‘70s Albums






















[http://www.it-ebooks.info](http://www.it-ebooks.info)
John Lennon/Plastic Ono Band 1970
Imagine 1971
Some Time in New York City 1972
Mind Games 1973
Walls and Bridges