What does JQuery mean?
It is simply a light weight javascript library through which we can perform actions like "DOM Elements" selection, Event handling, Animation effects, Ajax calls etc with minimal code. In short we can say " write less,do more" with JQuery.
Why should we use JQuery?
- Makes it easy to use javascript with minimal lines of code in websites.
- Multiple browser Compatability i.e It works in almost 25+ browsers (IE,FireFox,Chrome,Safari,Netscape) unlike Javascript which behaves differently on differnt browsers.
- There are many plugins available for programming ease.
- It uses a chaining mechanism for DOM elements selection while developing code, which makes it more easy to write and understand in websites.
Step 1: Jquery Reference
Step 2: JQuery Intellisense for .NET
Basic selectors in JQuery for selecting Dom elements in web page:
Selector | Example | Operation |
* | $("*") |
All Elements in a page |
#id | $("#btnSubmit") |
The element with id=btnSubmit |
.classname | $(".title") |
The element with classname=title |
#id1,#id2,#id3 etc | $("#btnSubmit,#btnAdd,#btnCancel") |
All Elements with id=btnSubmit or id=btnAdd or id=btnCancel |
.classname1,.classname2,.classname3 | $(".title,.head,.body") |
All Elements with classname=title or classname=head or classname=body |
Element | $("div") |
All Elements in page
|
Element1, Element2, Element3 | $("div,p,h1") |
All ,
and elements |
parent > child | $("div > p") |
All elements that are a direct child of a element
|
[attribute] | $("[href]") |
All elements with a href attribute |
[attribute=value] | $("[href='default.htm']") |
All elements with a href attribute value equal to "default.htm" |
:input | $(":input") |
All input elements |
:text | $(":text") |
All elements with type=text |
These are a few basic tips on jquery which i like to share with the developers. More information on Jquery and optimization techinques to be coming soon.