Images

JQuery - PART I


jQuery
jQuery is great library for developing Ajax based application; It is also a great library for JavaScript script programmer, that makes it easy to create wonderful web effects in just a few lines of code . It was released in January 2006 at BarCamp NYC by John Resig.You can use jQuery to develop cool web 2.0 applicationsjQuery helps the programmers to keep code simple and concise. The jQuery library is designed to keep the things very simple and reusable.img
jQuery is java script and can be used with JSP, Servlets, ASP, PHP, CGI and almost all the web programming languages.
JQuery is nothing but simply call a JavaScript base library. It adds syntax to the JavaScript language to ease working with the DOM.


Introdunction With JQuery
Introduction
jQuery is great library for developing Ajax based application; It is also a great library for JavaScript script programmer, that makes it easy to create wonderful web effects in just a few lines of code . It was released in January 2006 at BarCamp NYC by John Resig.
You can use jQuery to develop cool web 2.0 applications. jQuery helps the programmers to keep code simple and concise. The jQuery library is designed to keep the things very simple and reusable.
jQuery is java script and can be used with JSP, Servlets, ASP, PHP, CGI and almost all the web programming languages.
"JQuery is nothing but simply call a JavaScript base library". It adds syntax to the JavaScript language to ease working with the DOM. The library of JQuery is designed to keep the things very simple, easier, effective and reusable.
jQuery library simplifies the process of traversal of HTML DOM tree. You can use jQuery to handle events, perform animation, and add the ajax support into your web applications with ease.

Introdunction With JQuery
Why jQuery?
jQuery is simple to understand and easy to use, which means the learning curve is small, while the possibilities are (almost) infinite. By using simple JavaScript you can perform all the functions that jQuery provides.
But the jQuery library is providing many easy to use functions and methods to make rich applications. These functions are very easy to learn and even a designer can learn it fast.
Due to these features jQuery is very popular and in high demand among the developers. You can use jQuery in all the web based applications irrespective of the technology.
Instead of writing more coding as in JavaScript to build a script for validation it takes only a few lines for that to make a more impressive and dynamic application, that’s why we can use this instead of JavaScript.
User may be confused by assuming this is a new technology, but it is not a new technology instead of, it is a combination of the JavaScript, html and the css.
jQuery library simplifies the process of traversal of HTML DOM tree. You can use jQuery to handle events, perform animation, and add the Ajax support into your web applications with ease.
Some Points we summarize here which describe the functionality of JQuery overJavaScript.
Never include JavaScript events as inline attributes. This practice should be completely wiped from your mind.
< a onclick="doSomething()" href="#">Click!< /a>
All JavaScript behaviours should be included in external script files and linked to the document with a < script> tag in the head of the page. So, the anchor tag would appear like this:
< a href="backuplink.php" class="doSomething">Click!< /a>
Understanding Selectors: the Backbone of jQuery.

Introdunction With JQuery
Technology Used in JQuery:
jQuery is a client-side library built on top of JavaScript , the jquery uses many others technology to produce a effective product, these are of the following types.
1. HTML

2. C.S.S

3. JAVASCRIPT
When you can use JQuery?
JQuery is much more powerful expressive, easy to use and less doing of code, it is basically a small library that gives you powerful control over the Document Object Model, with a very little effort or work on your part.
It can be used to anybody who wants to:
• Quick access to AJAX

• Without access to AJAX

• And some basic animation effects to spice things up

Introdunction With JQuery
Features & Facts of JQuery
With its great features query can be used in JSP, SERVLET, ASP, PHP, CGI and almost all the web programming languages.
Here we short out the list of the features of JQuery.
• Ajax

DOM element selections functions using the cross browser open source selector engine.

Effects and animations 

DOM traversal and modification

Events

JavaScript Plugins

CSS manipulation

Extensibility

Utilities - such as browser version and the each function.

The $ function• One of the critical concepts in any jQuery code is the so called ‘$’ function. ‘$’ is actually an ‘alias’ for the ‘jQuery’ namespace.
Facts about JQuery:
• The size of the jquery is about 19 kb in size.

• It supports CSS 1-3 and also the basic XPath.

• We can use the prototype and jquery together, without any problem.

• JQuery owns a strong and very flexible mechanism for adding in methods and functionality, bunduled as plugging.

• It supports in Firefox 1.0+, IE5.5 and Safari 1.3 and Opera 8.5.

Introdunction With JQuery
Example Explaining the working of Jquery:
JQuery is, as we explained is a very easy client side script used on web application, it is basically a best use of JAVASCRIPT (X)HTML and the CSS, with a suitably use of these the result produces will be more effective expressive and dynamic as compare to normal JavaScript .
The jquery is simply produces the base result of as like JavaScript but of better looks and visibility.
Let’s take an example:
To filling a simple form (As a registration form, login form or etc.) use of JavaScript in many fields are ment be necessary, JavaScript gives with an alert with a window base pattern, when a users fills a wrong entry, the window will appears with an alert message, when we cut (X) or close the window, it disappears, normally JavaScript is having a same way to a client side validation but it’s a very old fashioned and do not looks good for all application, it seems to be a old fashioned warinig concept, but while on useing jquery(/Ajax) it will applies the filter with a different pattern of alert messages, which give a fresh look to your web site, there are many types of way to display the alert in the JQuery which makes jquery more impressive, powerful and strong and which increases page’s beauty more.
Like the alert comes below each field as a statement (with proper using of css and use of image. Comes a different type of window with increasing slowly and on close, it close with different style.
There are many more examples, some of them are explain here, but before that you can understand the basic thinks of the jquery, We can teach you each an every thing with explanation, and at the last give you the whole example of jquery with the explanation, demonstration and code, in other section, so that you can learn and apply that in your script

Module 2
GETTING STARTED WITH JQUERY
The first article of the jquery begins here by exploring the syntax of jquery, how it is set up, and how its functions are called. Later than we explain the core functions in the library and how it uses its powerful selectors and filters to make DOM traversal easy and straightforward. This tutorial is basically for that who have the prior knowledge about basics JavaScript s, css syntax and the DOM syntax.
Before getting the fun with jquery, we need to get the basics, out of the way- how to install it and how to start and so on.
Functions:
Before we explain about jquery, I want to explain the selectors, attributes and functions used in the jquery.
Selectors
The term “Selectors” are used in jQuery, it serves some of the best features to jQuery, when it comes to dom manipulation. They allow you to quickly select all elements or groups of elements of a given tag name, attribute name or their contents and allow you to manipulate them as a group or a single node.
Example of jQuery selectors
Some of the main Selector which is frequently used in jquery is listed below:
1. #id – This selector is most commonly used selector which matches a simgle element with the given id attribute.
Example:
$("div").css("border"," 5px solid green");
2. element- This selector is also commonly used, This selector will collect all elements in a document with the given tag name i.e. table, ul, li, a etc.
Example:
$("div").css("border"," 5px solid green");
Note:* It differs from the ‘id ‘attribute (above one) only for it select all the div with the given name in the script.
3. class- The class selector will mathes all elements in the document with the given class name.
Example:
$(".myClass").css("border","3px solid red");
4. class- Matches all the element with the given classes.
Example
$(".myClass").css("border","5px solid green");
5. selector1, selector2, and selectorN- This selector is for the matches of combined result of the specified selector.
Example:
$("div,span,p.myClass").css("border","3px solid red");
Here we describe about the basic terms used in the jQuery –
1- :hidden – It is used for matching all of the elements which are hidden.
Example:
 $("span:first").text("We here found total of  " + 
$(":hidden", document.body).length +" hidden elements ");
   $("div:hidden").show(3000);
$("span:last").text( $("input:hidden").length + " hidden  inputs are found here.");
2- : visible – It is just reverse of the hidden it matches all of the elements which are visible.
Example:
$("div:visible").click(function () {
                  $(this).css("background", "yellow");
});
$("button").click(function () {
$("div:hidden").show("fast");
});
Some of the term is used as a filter/separator, which are commonly used as a filter to separate the term.
1- : First – It matches the element which is to be selected first.
Example:
$("tr:first").css("font-style", "bold");
First Element

Second element

Third Element
2- : Last – It matches the element which is selected last.
Example:
$("tr:last").css({backgroundColor: 'red', fontWeight: 'bolder'});
First Element

Second element

Third Element
3- : Not (selector) – It filters out the all the element matching the given selector.;
Example:
$("input:not(:checked) + span").css("background-color", "orange");
$("input").attr("disabled", "disabled");
4- : Even – It matches the even no of elements.
Example:
$("tr:even").css("background-color", "996699");
5- : Odd – It matches the odd no of elements.
Example:
$("tr:odd").css("background-color", "#996699");
6- : Header -It matches all the element that are headers, like h1, h2, h3 and so on.
Example:
$(":header").css({ background:'#CAB', color:'green' });
Attribute filters-
• [attribute]- Matches elements that have the specific attribute.
Example:
  $("div[id]").one("click", function(){
      var strId = $(this).text() + " = " + $(this).attr("id");
      $(this).text(strId);
    });
[attribute=value]- Matches elements that have the specific attribute with a certain value. A little more definition and tone comes in through this selector. We can use the < a> element again. For example, use$('[href=http://www.ebizelindia.com]') to select all < a> elements with a link to foxnews, the only reputable news source in America (of course).
Example:
$("div[id]").one("click", function(){
      var strId = $(this).text() + " = " + $(this).attr("id");
      $(this).text(strId);
    })
• [attribute!=value] - Matches elements that either don’t have the specific attribute or do have the specific attribute but not having a certain value.There are many of the filter are there expect them, which will be known by you on practicing more example.
Example:
$("input[name=attrName]").next().text(" a text ");
Now after a short view on the elements used in jquery let us we describe the basic term used form:
Inputs- it matches all the inputs, text area, select and button elements etc. It Returns only input Elements of the tag name input, select, text area and button.
Example:
var totalinput = $(":input");
var formChild= $("form > *");
$("#messages").text("Found " + totalinput.length + " inputs are  called, form has " +
  formChild.length + " children.");
;
: Text – it matches all the inputs of the text type.
Example:
var txtInput = $("form input:text").
css({background:"red", border:"5px
	 yellow solid"});
    $("div").text("For this type jQuery found " + txtInput.length + ".")
            .css("color", "green");
: Password – matches all the input element of typed password.
Example:
var inputPass = $("input:password").
	css({background:"red", border:"5px red solid"});
 $("div").text("A Password Field is  found " + inputPass.length + ".")
 .css("color", "green");
Some more Selectors-
: Enable- It is used in a script to display all the inputs that are enable.
Example:
$("input:enabled").val("enable field");
: Disable- It is used in a script to display all the inputs that are disable.
Example:
$("input:disabled").val("disable field");
Like these all the others element have the same meaning with respect to its name.

0 comments: