javascript pocket guide [burdette]

Page 169

142

The JavaScript Pocket Guide

querySelectorAll(selector) Not available in Internet Explorer 6 or 7 The querySelectorAll() method works the same as querySelector() except that it returns all elements that match selector. Unlike getElementsByTagName(), querySelectorAll() returns a static list that doesn’t automatically update when the DOM changes.

Creating Nodes The DOM provides a few methods to create new nodes. In addition, Microsoft created a nonstandard way of creating nodes that had enough beneďŹ ts to be adopted by modern browsers.

Using DOM Methods The DOM methods are great for when you want to create one node at a time.

createElement(tagName) Creating element nodes is as simple as passing the desired tag name to document.createElement(). Unlike many DOM methods, createElement() is available only on the document object. document.createElement("div"); <div> document.createElement("a"); <a> document.createElement("body"); <body>


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.