Return to Video

Pulling HTML and Text

  • 0:00 - 0:05
    I hope by this point you're starting to
    see the power of jQuery's DOM methods.
  • 0:05 - 0:09
    Up to now you've selected elements and
    learned about the data inside HTML tags.
  • 0:10 - 0:15
    But what about the data held between
    tags, can you grab that with jQuery too?
  • 0:15 - 0:16
    Yep.
  • 0:16 - 0:18
    The two best options for
  • 0:18 - 0:22
    finding all of the data between
    tags are .html() and .text().
  • 0:23 - 0:26
    I'll open up the Udacity homepage and
    demonstrate the difference between them.
  • 0:27 - 0:29
    Feel free to follow along with me.
  • 0:30 - 0:35
    I started by selecting this element,
    with the ID of flyup-homepage,
  • 0:35 - 0:37
    you can see that it has
    other elements inside of it.
  • 0:38 - 0:42
    If you run .html() in this selected
    element, you'll see the HTML of
  • 0:42 - 0:46
    everything inside of the flyup-homepage
    including all of the tags, classes,
  • 0:46 - 0:50
    and attributes, like so,
    here's the HTML.
  • 0:50 - 0:54
    But if you run .text() on a selection
    you'll see that jQuery has
  • 0:54 - 0:59
    stripped out all of the HTML tags, and
    only return the text contained within.
  • 0:59 - 1:02
    Like so,
    we can see the HTML disappeared.
  • 1:02 - 1:08
    But can you change the HTML and text
    of a DOM element with these methods?
  • 1:08 - 1:09
    Let's go ahead and find out.
Cím:
Pulling HTML and Text
Leírás:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
ud245 - Intro to JQuery
Duration:
01:10

English subtitles

Felülvizsgálatok Compare revisions