Practical prototype and part 6:The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | CHAPTER 2 Prototype Basics JavaScript libraries don t start out as libraries. They start out as helper scripts. It s possible but impractical to do DOM scripting without the support of a library. Little things will start to annoy you from day one. You ll get tired of typing out so you ll write an alias. Then you ll notice that Internet Explorer and Firefox have different event systems so you ll write a wrapper function for adding events. Then you ll become irritated with a specific oversight of the language itself so you ll use JavaScript s extensibility to write some code to correct it. Then one day you ll notice your helper script is 35 KB. When organized and divided into sections you ll realize you ve got a library on your hands. All JavaScript libraries start out as caulk between the cracks. For this reason a lesson in using Prototype begins not with an in-depth look at any particular portion but rather with a whirlwind tour of many of the problem-solving constructs you ll use most often. In this chapter we ll take that tour. Getting Started Let s keep using the web page we wrote in the previous chapter. Open up and add some content to the page s body DOCTYPE html PUBLIC - W3C DTD XHTML Transitional EN http TR xhtml1 DTD html xmlns http 1999 xhtml xml lang en lang en head meta http-equiv content-type content text html charset utf-8 script type text javascript src script title Blank Page title head 17 18 CHAPTER 2 PROTOTYPE BASICS body h1 Blank Page h1 ul id menu li id nav_home class current a href Home a li li id nav_archives a href archives Archives a li li id nav_contact a href contact Contact Me a li li id nav_google a href http rel external Google a li ul body html We re adding an unordered list with links as list items the typical structure for a web site s navigation menu. Each li element has an ID. The final a element has a rel attribute with a .