Categories

Using jQuery In Your Website

For jQuery to work the elements on the page must be ready for it to be manipulated and used.  Only once the DOM is loaded is when jQuery can then take effect. In order to start using jQuery we must include two things. One is the latest jQuery file which can be downloaded from the jQuery.com website, or also included directly from the Google code repository. The second thing you need to do is include a standard function that will prepare the browser for our jQuery commands.

The code is

$(document).ready(function() {
            alert(‘You have successfully loaded jQuery’);
});

The code above is informing the browser that when the document is ready to run whatever is in between the curly brackets. In this case we used

alert(‘You have successfully loaded jQuery’);

which is a regular JavaScript function that issues a message for the user to see.

There is another way to start jQuery. The shorthand version that is as follows

$(function() {
            alert(‘You have successfully loaded jQuery’);
});

The above code will handle exactly the same as the code described previously. It is really up to you to decide which way you prefer. Either way is perfectly acceptable.

Remember that all your code from now on will go within these functions. Without these functions your code will not run.

Contact Details

Frank Perez Contact Information

Frank Perez
Phone: 1-954-560-8165
Email: frank@frankperez.net

Messengers:
MSN: frank@frankperez.net
AIM: frankperez87
G-Talk: frankperez87@gmail.com
Skype: frankperez87

Contact Frank Perez