Web Development with jQuery®

(Elliott) #1

(^8) ❘ CHAPTER 1 INTRODUCTION TO JQUERY
Therefore, if I were using the domain example.com, jQuery would have this path from the document
root, /jQuery/jQuery.js. You do not have to install jQuery at this exact path. You can move jQuery
wherever you like, but don’t forget to update the path.
HELLO, WORLD IN JQUERY
In the following example you learn how to install jQuery and execute a remedial
“Hello, World” jQuery-based JavaScript application. To start, follow these steps:



  1. Download the jQuery script from http://www.jquery.com. Alternatively, I have also
    provided the jQuery script in this book’s source code download materials
    available for free from http://www.wrox.com/go/webdevwithjquery.

  2. Enter the following XHTML document, and save the document as Example
    1-1.html. Adjust your path to jQuery appropriately; the path that I use refl ects
    the path needed for the example to work when opened in a browser via the
    source code materials download made available for this book.


<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type"
content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="content-language" content="en-us" />
<title>Hello, World</title>
<script type='text/javascript' src='../jQuery.js'></
script>
<script type='text/javascript' src='Example 1-1.js'>
</script>
<link type='text/css' href='Example 1-1.css'
rel='stylesheet' />
</head>
<body>

</body>
</html>


  1. Enter the following JavaScript document, and save the document as Example
    1-1.js:
    $(document).ready(
    function()
    {
    $('body').append(
    $('
    ')
    .addClass('selected')


http://www.it-ebooks.info

Free download pdf