What is JQuerry ?
jQuery is A JavaScript library. jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. jQuery is free, open-source software licensed under the MIT License.
jQuery was introduced in January 2006 by John Resig at BarCamp NYC.
jQuery also offers functionality that allows developers to build plug-ins, in addition to the JavaScript library. This allows for the development of abstractions for animation and low-level interaction, sophisticated effects and themeable, high-level widgets. The modular mechanism of the jQuery library facilitates the development of highly effective, potent Web applications and Web pages.
The jQuery library provides several user friendly strategies and functions for rich application development. Because the functions of jQuery are simple, it is very popular among developers. jQuery may be used in all Web based applications, in spite of the technology. It may be used with ASP, PHP, JSP, CGI, Servlets and most Web programming languages.
How to add JQuery ?
Adding Remotely
You can add JQuery remotely by using following syntax
Syntax:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js?ver=1.4.0">
</script>
Adding from your local folder
Download the above library from official website http://jquery.com. place your file in to your local folder and add using following Syntax
Syntax:
<script type="text/javascript" src="<!-- Place your local folder address here-->/jquery.min.js?ver=1.4.0">
</script>
e.g.
<script type="text/javascript" src="js/jquery.min.js?ver=1.4.0">
</script>
Note: Js is the local folder where i have placed my JQuery file name jquery.min.js.
You need Document Ready ().
The first thing you need to be up and running with jQuery is what’s called the “document ready” handler.
Here is what it looks like:
$(document).ready(function() {
// all jQuery code goes here
});
or
$function(){
// all jQuery code goes here
}
Selecting Elements in jQuery
The jQuery library allows you to select elements in your XHTML by wrapping them in $("") (you could also use single
quotes), which is the jQuery wrapper. Here are some examples of “wrapped sets” in jQuery:
$("div"); // selects all HTML div elements
$("#myElement"); // selects one HTML element with ID "myElement"
$(".myClass"); // selects HTML elements with class "myClass"
$("p#myElement"); // selects HTML paragraph element with ID "myElement"
$("ul li a.navigation");
// selects anchors with class "navigation" that are nested in list items
jQuery supports the use of all CSS selectors, even those in CSS3. Here are some examples of alternate selectors:
$("p > a"); // selects anchors that are direct children of paragraphs
$("input[type=text]"); // selects inputs that have specified type
$("a:first"); // selects the first anchor on the page
$("p:odd"); // selects all odd numbered paragraphs
$("li:first-child"); // selects each list item that's the first child in its list
jQuery also allows the use of its own custom selectors. Here are some examples:
$(":animated"); // selects elements currently being animated
$(":button"); // selects any button elements (inputs or buttons)
$(":radio"); // selects radio buttons
$(":checkbox"); // selects checkboxes
$(":checked"); // selects checkboxes or radio buttons that are selected
$(":header"); // selects header elements (h1, h2, h3, etc.)
Nice Blog!!
ReplyDelete