Return to Video

jQuery Documentation and You - Intro to jQuery

  • 0:01 - 0:05
    For this lesson, you'll be focusing on practicing DOM manipulation methods.
  • 0:05 - 0:10
    You'll start by accessing data about existing nodes and modifying that data.
  • 0:10 - 0:12
    You'll finish by adding and removing DOM elements.
  • 0:13 - 0:16
    I won't be covering all of jQuery's methods, but
  • 0:16 - 0:19
    most of them follow pretty much the same pattern.
  • 0:19 - 0:20
    And after these examples,
  • 0:20 - 0:23
    you won't have any problem tackling additional methods.
  • 0:24 - 0:26
    This is the jQuery API documentation.
  • 0:26 - 0:29
    On the left, you can see the main types of jQuery methods.
  • 0:29 - 0:35
    I want to start by modifying the class attribute, so I'll click on Attributes.
  • 0:35 - 0:37
    I can see a few methods.
  • 0:37 - 0:39
    I'll go ahead and start with addClass,
  • 0:39 - 0:43
    which does pretty much exactly what you think it does.
  • 0:43 - 0:46
    It adds a specified class to a DOM element.
  • 0:46 - 0:50
    This black box shows the main function signature, which tells you what to
  • 0:50 - 0:54
    pass in as an argument to this method to get it to work properly.
  • 0:54 - 0:56
    This description is pretty useful.
  • 0:56 - 1:00
    It looks like this method takes in a string of a class name and
  • 1:00 - 1:02
    adds it to selected elements.
  • 1:02 - 1:04
    So if I passed in blue to this method,
  • 1:04 - 1:08
    I'd add the blue class to the element with the ID of item.
  • 1:08 - 1:12
    Inside the black box, you could find different ways of using the method,
  • 1:12 - 1:15
    including this one, where you could pass a function to addClass.
  • 1:15 - 1:17
    Huh, that seems kind of weird.
  • 1:18 - 1:22
    If I read further though, we see that this function must return a string.
  • 1:22 - 1:25
    It could be a string of a single class name or
  • 1:25 - 1:28
    it could be many class names separated by spaces.
  • 1:28 - 1:33
    And then below, we have some in-depth discussion and some examples.
  • 1:33 - 1:34
    That's pretty cool.
  • 1:34 - 1:37
    In other examples, like .parents, for
  • 1:37 - 1:40
    instance, you'll see parameters inside square brackets.
  • 1:40 - 1:44
    The square brackets mean that the parameter is optional and
  • 1:44 - 1:47
    the method will work just fine with or without it.
  • 1:47 - 1:49
    Now that I've walked you through the documentation,
  • 1:49 - 1:53
    I want you to try parsing some documentation for yourself.
  • 1:53 - 1:55
    You're going to start by modifying some data in the DOM.
Cím:
jQuery Documentation and You - Intro to jQuery
Leírás:

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

English subtitles

Felülvizsgálatok Compare revisions