This article gives a brief introduction about what is Jquery and what can be done using JQuery.
JQuery is a Java script libarary/ Java Script framework that simplifies the interaction process or access process of traversing in HTML document. It provides methods to make animations, add ajax interaction to the page, provides an easy way to apply CSS to any items and provides an easy mechanism for binding and unbinding events. Huge code written using Java script can easily replaced by few lines of code in JQuery.
History of JQuery
Initially it's was released in January 2006 but the very first stable version of JQuery 1.0 was released in August 2006. This version had support for CSS, events and Ajax. After that many version of JQuery were released but the latest version is JQuery 1.3.2. You can download this from JQuery website.
What can be done using JQuery
1. Allows to access elements in the document
2. Easily apply CSS
As it's known that CSS is the most powerful and mostly used for good appreance of any webpage. JQuery provides CSS Selectors which allows to change the CSS classes or individual style for any portion of the document. This can be done even after the page is rendered.
3. Make Animations
For better user experience, animation can do the job for you. JQuery provides many methods to perform animations like show,hide, fade, wipe, start, stop etc. Doing all this with JQuery is fun as No huge lines of code, no complex logic.
4. Ajax Interaction
In today's world, Ajax is one of the most popular technology used in almost every website for better user experience. Jquery provides support for ajax also which allows to access server side event without refreshing the web page.
5. API to change document's content
JQuery provides API (Application Program Interface) which allows to change the content of the document. Changing Text, inserting images, ordering of list can be done with few keystrokes with JQuery API. Entire structure of HTML can be rewritten or extended.
6. Event handling
Any technology is a failure if it cannot responsed to the user when any event takes place. Jquerys's event handling is one the decent feature. It quickly responsed to any event such as user clicking a button.
To start with JQuery, first download the Jquery from it's official website
(http://JQuery.com). Make sure you download the latest copy of the JQuery.
No installation is required, you just need to add reference of the Jquery.js.
I have copied the jquery.js and placed it in script directory of the project. In this demo, I am going to show you how easily you can change the CSS and do animation.
Let's first take a look at HTML
History of JQuery</h2>
Initially it's was released in January 2006 but the very first stable version of JQuery 1.0 was released in August 2006. This version had support for CSS,events and Ajax. After that many version of JQuery were released but the latest version is JQuery 1.3.2. You can download this from JQuery website.
As you can see, I have placed a div tag with it's ID set to content. Now, I will show you how you can find the div and apply CSS to it using JQuery.
.ready() is a jQuery event handler. This particular event handler will execute when the document is ready to be accessed
and scripts have completed loading. A .ready() handler can be
placed anywhere on the page
and you can
even have multiple ready handlers in the page.
Now, if you run this page, you will see the div with content id is having gray background and white color foreground.
Let's go to the animation part with JQuery.
Place a button and some text in Paragraph tag. Using JQuery, I will add a click event handler.
<asp:Button ID="btnShow" runat="server" Text="Show" />
<p style="display: none;background-color:Red">
Now add this Jquery code to document.ready event
Above code will find the btnshow and add a click event handler to it. When the button is click then Jquery will find the p tag and make a call to show function which will display the content of the p tag on the screen.
Like wise there are many more functions for animation. You can find the whole list over here.
This is just an overview of starting with Jquery. Many more complex things can be done via jquery with ease. Go to this main page of Jquery
and learn as much as you can.