Web Development with jQuery®

(Elliott) #1

(^118) ❘ CHAPTER 4 MANIPULATING CONTENT AND ATTRIBUTES





The following style sheet is applied to the preceding markup document:
body {
font: 12px "Lucida Grande", Arial, sans-serif;
color: rgb(50, 50, 50);
margin: 0 ;
padding: 15px;
}
div {
padding: 5px;
border: 1px dashed black;
background: orange;
margin: 5px 0 ;
}
div p {
margin: 5px;
}
The following script demonstrates jQuery’s wrap method:
$(document).ready(
function()
{
$('p').wrap('
');
}
);
In Figure 4-14, you see that each

element is wrapped in a

element, which is made obvious
by the styles applied in the style sheet. Each
has a distinct border, margin, and background
color applied to make it obvious that a
exists.

FIGURE 4-14


http://www.it-ebooks.info