I assume that we know what jQuery is. Well to brush it up, “jQuery is a javascript library that makes our life easier”
. I like to define in that way. Ok, now in this post, I’m gonna show you how to get things started for jQuery. As you can read this blog, it’s obvious that you have an Internet connection and of course you’re using some browser. So let’s just try one piece of code before making the post lengthy. Before that let’s see what we need for that
- jQuery Library (download from http://jqueryjs.googlecode.com/files/jquery-1.2.6.js) This is the current release when I’m writing the post.
- A modern browser (IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+) with javascript enabled.
- And a text editor (my Fav is notepad++)
I suppose we all know how does a basic html page look like. We’d just run a simple piece of code adding jQuery library
Now, just copy and paste the above code and save it calling “jquery-test.html”.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>My Jquery Playground</title>
<script src=”jquery-1.2.6.js” type=”text/javascript”></script>
<script type=”text/javascrpt”>
$(document).ready(function(){
alert(“Muhahaha”);
});
</script>
</head>
<body>
</body>
</html>
And now you can run the code by double clicking the file you have just created. Have you clicked ? and can you see the laughter (“Muhahaha”) ? If Yes, then we have just started to use jQuery.
Now I think we need little bit of an explanation of what we did in the above code.
First, we have started with a very basic html template
Secondly, we just added the jQuery javascript library using
<script type=”text/javascrpt” src=”jquery-1.2.6.js”></script>
And then we wrote a javascript block
<script type=”text/javascrpt”>
$(document).ready(function(){
alert(“Muhahaha”);
});
</script>
what did it do? well, $(document).ready(function(){ ..blah blah }); means execute “blah blah” code when page (document) loads. Perhaps writing
$(function(){
alert(“Muhahaha”);
});
would do the same thing.
EASY, huh ?
So you have just got started with jQuery. Check the other posts for little bit more fun & Magics.
For more reading, visit jquery.com site.










































Recent Comments