12.07.2015 Views

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 2 GETTING STARTED...Submit Order...• Tip If the selector that I passed to the appendTo method had matched multiple elements, then jQuery wouldduplicate the elements from the HTML fragment and insert a copy as the last child of every matched element.jQuery defines a number of methods that you can use to insert child elements into the document,and the most useful of these are described in Table 2-2. When you append elements, they become thelast children of their parent element. When you prepend elements, they become the first children of theirparents. (I’ll explain why there are two append and two prepend methods later in this chapter.)Table 2-2. jQuery Methods <strong>for</strong> Inserting Elements in the DocumentMethodappend(HTML)append(jQuery)prepend(HTML)prepend(jQuery)appendTo(HTML)appendTo(jQuery)prependTo(HTML)prependTo(jQuery)DescriptionInserts the specified elements as the last children of all the elementsin the DOMInserts the specified elements as the first children of all the elementsin the DOMInserts the elements in the jQuery object as the last children of theelements specified by the argumentInserts the elements in the jQuery object as the first children of theelements specified by the argumentApplying a CSS ClassIn the previous example, I inserted an a element, but I did not assign it to a CSS class. Listing 2-6 showshow I can correct this omission by making a call to the addClass method.22www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!