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 > Getting and Setting Text Content

1.17. Getting and Setting Text Content

1.17.1. Problem

You need to get or set the text that is contained inside of an HTML element(s).

1.17.2. Solution

jQuery provides the text() method for getting and setting the text content of elements. In the following code, we use this method to set and then get the text value of the <p> element found in the HTML document:


  

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