Web Development with jQuery®

(Elliott) #1

Installing jQuery (^) ❘ 9
.attr({
id : 'body',
title : 'Welcome to jQuery'
})
.text(
"Hello, World!"
)
);
}
);



  1. Enter the following CSS document, and save the document as Example 1-1.css:


body {
margin: 0 ;
padding: 20px;
font: 14px Helvetica, Arial, sans-serif;
}
div.selected {
background: blue;
color: white;
padding: 5px;
display: inline-block;
}

The preceding code results in the screen shot that you see in Figure 1-1 if the instal-
lation were unsuccessful. If installation were not successful, the page appears
blank.

FIGURE 1-1


In the preceding example, you installed and tested your installation of the jQuery framework.


The JavaScript that you included is executed when the document’s onready event is fi red, which is


executed as soon as the DOM is fully loaded: all markup, JavaScript, and CSS, but not images. The


callback function attached to the onready event then creates a

element with the selected class


name and contains the text Hello, World!


You have now used jQuery for the fi rst time.


http://www.it-ebooks.info

Free download pdf