Using jQuery to Create/Change Content

jQuery makes it very easy to create new page content and change existing page content.

Content Creation

Creating new content is as simple as passing a string of HTML to the $() function.

For example, $("<p>") creates a new, empty paragraph tag. To add new content to the paragraph, you could simply write $("<p>").append("<em>Hello there</em>").

Changing Content

There are multiple ways to change page content using jQuery, depending on your needs.

The html() and text() functions can be used to directly manipulate the contents of elements, and there are ways to control how content can be inserted and moved around in the page.