02.06.2013 Views

DOM Traversal Methods

DOM Traversal Methods

DOM Traversal Methods

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ 75 ]<br />

Chapter 4<br />

Parameters<br />

• value: A string of text to set as the value property of each matched element<br />

Return Value<br />

The jQuery object, for chaining purposes.<br />

Description<br />

This method is typically used to set the value of form fields.<br />

<strong>DOM</strong> Insertion, Inside<br />

.prepend()<br />

Inserts content, specified by the parameter, at the beginning of each element in<br />

the set of matched elements.<br />

.prepend(content)<br />

Parameters<br />

•<br />

content: An element, HTML string, or jQuery object to insert at the beginning<br />

of each element in the set of matched elements<br />

Return Value<br />

The jQuery object, for chaining purposes.<br />

Description<br />

The .prepend and .prependTo methods perform the same task. The only difference<br />

is in the syntax—specifically, in the placement of the content and target. With<br />

.prepend(), the selector expression preceding the method is the container into<br />

which the content is inserted. With .prependTo(), on the other hand, the content<br />

precedes the method, either as a selector expression or as markup created on the fly,<br />

and it is inserted into the target container.<br />

Consider the following HTML:<br />

<br />

Demonstration Box<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!