02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

which returns the following in the console:<br />

>>> $("p span:last");<br />

[ span.foo ]<br />

CHAPTER 1 ■ INTRODUCING JQUERY<br />

However, if you needed to find every span that was the last child of a paragraph element, you would<br />

use :last-child instead:<br />

$("p span:last-child");<br />

This uses each parent as a reference instead of the DOM as a whole, so the results are different:<br />

>>> $("p span:last-child");<br />

[ span, span.foo ]<br />

Form Filters<br />

Forms are a huge part of web sites these days, <strong>and</strong> their major role inspired a set of filters specifically<br />

geared toward forms.<br />

Because your HTML example does not have any form elements in it, you’ll need to append the file<br />

with some new markup for the following examples.<br />

In index.html, add the following HTML between the last paragraph tag <strong>and</strong> the first script tag:<br />

<br />

<br />

Sign Up Form<br />

Name<br />

<br />

Password<br />

<br />

<br />

<br />

I'm on my computer<br />

<br />

<br />

<br />

I'm on a shared computer<br />

<br />

<br />

<br />

<br />

Keep me signed in on this computer<br />

<br />

<br />

<br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!