This website stores cookies. Click here to accept them.cookie information page

What is jQuery?

21st December 2011
Categories: basics, javascript

I'm building a shed in my garden. What I need is to put bikes, a lawnmower, a few tins of paint, a toolbox and some random junk under cover. That's the primary aim of the project.  The seconday aim is that it mustn't look too shabby.  And finally it mustn't be a lot of work to put up.

Now I know that the raw materials for building a shed are wood and nails, and maybe some glue. But it would be great if some of the pieces of wood came stuck together already, so that I didn't have to do so much hard work to achieve my goals.

Enter the pre-fabricated shed, and ta-da!  It takes less than half the time.

jQuery is basically a pre-fab shed for Javascript. Someone has spent a lot of time and energy building commonly-used routines and functions to do things like showing and hiding bits of web page, calendar controls, and that kind of thing, and once you have jQuery and some simple documentation you can access them very easily without all the hard work.

Take 'lightboxes' for example. They are a popup window in the middle of your web page to show an image. They can be part of a gallery and include 'previous' and 'next buttons'.

If you google 'jQuery lightbox' you'll get an example of this javascript at work, and a download link which gives you the jQuery core library and the lightbox library, and some sample code to get you started with your very own lightbox code.

The way a lot of jQuery works is by modifying attributes of existing HTML.  Say you have some HTML which looks like this:

<div class="someclass">
<ul>
   <li>
     <a title="Some random picture" href="pic.jpg">
        <img src="thumb.jpg">
      </a>
    </li>
</ul>
</div> 

The jQuery code for turning your thumbnail picture into a link to a lightbox happens in the Javascript at the top of the page, where you call a function to modify the action of the anchor tag.  Most of the work that's done is hidden from you (the coder), you simply call a jQuery function to turn  the div into a lightbox gallery.


Add your comment for "What is jQuery?":

© Alberon Ltd 2018

8 Standingford House
26 Cave Street
Oxford
OX4 1BA

01865 596 144

Oxford Web is a trading name of Alberon Ltd, registered company no. 5765707 (England & Wales).