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, Setting, and Removing DOM Element Attribute...

1.15. Getting, Setting, and Removing DOM Element Attributes

1.15.1. Problem

You have selected a DOM element using the jQuery function and need to get or set the value of the DOM element’s attribute.

1.15.2. Solution

jQuery provides the attr() method for getting and setting attribute values. In the following code, we are going to be setting and then getting the value of an <a> element’s href attribute:


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint