Thursday, December 9, 2010

JQuery - What? Why? How?

What is JQuery?
JQuery is a lightweight cross-browser JavaScript library. JQuery is designed to change the way that you write Javascript.


Why JQuery?
You can use simple JavaScript to perform all the functions that jQuery provides. Then why JQuery? It easy to create nice web effects in just a few lines of code. We may require 10-11 lines of code in Javascript to perform certain function, the same thing can be achieved through JQuery with just 1-2 lines of code (as it says Write less, Do More). And its very easy to learn too.


How to use it?
You can download the source code, from the jQuery website. There will two versions "Minified" and "Uncompressed".


Minified Vs Uncompressed
The minified version is best for the production environment. It will save you some bandwidth and some loading time. It is hard to debug.
The uncompressed version is for development, you can debug it.


How to use jQuery library in our ASP.Net project?
Once you have downloaded the JQuery and include the reference to the jQuery library file in your ASPX page.
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
        <script language="javascript">
            $(document).ready(function() {
            alert('test');
            });
        </script>


Launching Code on Document Ready
jQuery has a simple statement that checks the document and waits until the DOM is fully loaded.
Next, what is this $.. We can access the JQuery object using $. We can even use "jQuery" instead of $
eg: jQuery(document).ready(function() {
            alert('test');
            });

Hope this post will give you a brief idea about JQuery. You can learn more JQuery syntax here.


1 comment:

  1. Nice & simple post to differentiate javascript & jquery..

    ReplyDelete