This lesson covers
- Creating and injecting new HTML elements in the DOM
- Manipulating a jQuery collection
- Iterating over the elements of a jQuery collection
In this lesson you’ll discover how to create new DOM elements using the highly flexibile jQuery() function. The need to create new elements will occur frequently in your practice with the library. You’ll find yourself using this capability especially when we start discussing how to inject external data into a web page using JSON and the XML format and jQuery’s methods to work with Ajax.
In addition, you’ll learn other methods that are different from jQuery(). We’ll divide these methods into two parts. First, we’ll describe the methods that, starting from a jQuery collection, accept a selector as a parameter to create a new set of elements. For example, you’ll see a method that, starting from a set, creates a new set containing all the children of the elements in the initial set, optionally filtered using the selector passed as its argument. Then we’ll cover methods that aren’t strictly related to selectors but that allow you to iterate over the elements in a set or perform a test on them. Let’s get started!
Leave a Reply