jQuery in Action

74
CHAPTER 3
Bringing pages to life with jQuery
them. Please refer back to the syntax blocks for
append()
and
appendTo()
for the
format of the syntax for these commands.
One more thing before we move on...
Remember back in the previous chapter when we showed how to create new
HTML
fragments with the jQuery
$()
wrapper function? Well, that becomes a
really useful trick when paired with the
appendTo()
,
prependTo()
,
insertBefore()
,
and
insertAfter()
commands. Consider the following:
$('<p>Hi there!</p>').insertAfter('p img');
This statement creates a friendly paragraph and inserts a copy of it after every
image element within a paragraph element.
Figure 3.6 After execution, it's clear that the car has been moved and the flower has
been copied.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.