As we are now familiar with what JQuery is, let’s dig into JQuery Syntax and some examples.
JQuery API’s can be divided into categories depending on area of functionality handled:
- Selectors
- Attributes
- Traversing
- Manipulation
- Events
- Effects
- Ajax
- Utilities
What are these and which functionality they cover, we will cover with examples.
Let’s us first begin with basic ‘Hello World’ example then we will go through each category and have a look at specific category examples.
1) ‘Hello World’ Program: As this is our first JQuery Example, we will go though each and every detail as to how to do it. So here it goes:
a) Download the JQuery library. The library contains just a single file (jquery.js). We will be using 1.7.1 JQuery library version for our examples. Jquery can be downloaded from http://docs.jquery.com/Downloading_jQuery#Current_Release
b) Choose uncompressed version for development purpose. (Minified or compressed version are to be used in production environment)
c) Create a folder named ‘JQueryExamples’ and copy paste the jquery-1.7.1.js file in it. Now Open any text editor (notepad) and write your first jQuery program.
Let’s analyze the code and get an overview of JQuery structure:
- <script type=”text/javascript” src=”scripts/jquery-1.7.1.js”></script> => The HTML script tag points to JQuery library to be included.
- $(“document”) => Refers to the current HTML document
- $(“document”).ready() => The ‘ready’ method acts as an entry point and will be called each and everything the HTML page loads. All JQuery logic must be written here.
Stay tuned for more examples, will post them soon…
Leave a comment