Web Development with jQuery®

(Elliott) #1

(^90) ❘ CHAPTER 4 MANIPULATING CONTENT AND ATTRIBUTES
one or more elements, simultaneously. Retrieving an attribute’s value is also easy; after you’ve made
a selection, accessing an attribute’s value provides you with the attribute value of the fi rst element in
the selection. Finally, removing attributes is just as straightforward: When you remove an
attribute, it removes that attribute from each element in the selection. If you attempt to retrieve
an attribute after removing it, it returns undefined.
The following document, which appears in the source code download from http://www.wrox.com/go/
webdevwithjquery as Example 4-1, demonstrates these concepts:
<!DOCTYPE HTML>






The Marx Brothers









  • name='documentAttributeMarx'
    id='documentAttributeGrouchoMarx'
    value='Groucho' />



  • name='documentAttributeMarx'
    id='documentAttributeChicoMarx'
    value='Chico' />



  • name='documentAttributeMarx'
    id='documentAttributeHarpoMarx'
    value='Harpo' />



  • name='documentAttributeMarx'
    [http://www.it-ebooks.info](http://www.it-ebooks.info)
Free download pdf