DOM tree manipulation
The .attr()
and .prop()
methods are very powerful tools, and with them we can make targeted changes to the document. We still haven't seen ways to change the overall structure of the document though. To actually manipulate the DOM tree, you'll need to learn a bit more about the function that lies at the very heart of the jQuery
library.
The $() function revisited
From the start of this book, we've been using the $()
function to access elements in a document. As we've seen, this function acts as a factory, producing new jQuery objects that point to the elements described by CSS selectors.
This isn't all that the $()
function can do. It can also change the contents of a page. Simply by passing a snippet of HTML code to the function, we can create an entirely new DOM structure.
Note
Accessibility reminder
We should keep in mind, once again, the inherent danger in making certain functionality, visual appeal, or textual information available only to those with web browsers capable...