Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 1. jQuery Basics > Replacing DOM Elements

1.13. Replacing DOM Elements

1.13.1. Problem

You need to replace DOM nodes currently in the DOM with new DOM nodes.

1.13.2. Solution

Using the replaceWith() method, we can select a set of DOM elements for replacement. In the following code example, we use the replaceWith() method to replace all <li> elements with a class attribute of remove with a new DOM structure:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial