Getting Started

jQuery may be written using JavaScript, but unlike JavaScript, jQuery is not understood by browsers by default.

This is because jQuery is a framework designed to plug into your site. Because of this, there are many versions of jQuery, and is in constant development.


Adding jQuery to your web site is pretty easy. All you have to do is add a link to it in the header of your page.


The easiest way to link to jQuery, is to reference the files on the Google hosted libraries site:


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

This method of linking to the hosted version of jQuery has an added benefit. Not only do you not have to worry about hosting the files, but the chance of your site's visitor having a cached version of the file on their browser is high. This will speed things up when they access your site.

Writing your jQuery code is exactly the same as writing JavaScript code. Because of this, you can place your code in the page that is going to use it like this:


<script type="text/javascript">
    function MyFunction() {
      // Your code goes here in exactly the same way as if you were writing JavaScript code
    }

  </script>

You can also place it in a .js file, and reference it in your page in the same way that you reference the jQuery framework file.


If you called your .js file "Default.js" then this is how you will reference it:

<script type="text/javascript" src="Default.js"></script>


jQuery is text, so like JavaScript and html, you can write your jQuery code in any text editor. There are some really amazing editors that will make your coding much easier. One such editor is TSW Web Coder. There is a link to the TSW Web coder site at to top right of this page.

No comments:

Post a Comment