Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Thursday, 6 May 2010

JQuery Intro

Hi There,
If you are a web developer i am sure you must hear about JQuery if not it is a complete JavaScript library that can do what every you can think of into a web browser.

I will give you some tips how to work with JQuery so let's go
to work with JQuery do the following
1) include the core library (download the jquery-X.X.X.js) file from http://jquery.com/
2) include the file into you page as
<script src="jquery-1[1].3.2.js" type="text/javascript">
congratulation u now use jquery

so how to use it ?
very simple use jquery operator $(jqueryReference).jqueryFunction();
let's take it step by step,

the first part is $(jqueryReference) what is the jqueryReference ?
it should be one of this 5 notation:

1)no prefix  $('div') — Accesses all the div elements in the HTML(i.e any HTML tag :table,span,div,...)
2)# prefix  (hash prefix) $('#A') — Accesses all the HTML elements with id='A'
3). prefix(dot prefix) $('.b') — Accesses all the HTML elements with class='b'
4)nonElement = $.somefunction();(used as independent function like $.ajax({...}); )
5) a css selector which is a littel bit complex ($("div > div > span").doSomething() which will get all the spans that is inside div and this div is inside another div)
jqueryReferences may add to them something called custom selectors like
$('div : even'),$('div : odd') ,$('div : eq(0)') and  ......
$('div : even').someFunction() that will select only the even div in the document and apply someFunction() to them so if your code is like
<div> 0 </div>
<div> 1 </div>
<div> 2 </div>
<div> 3 </div>
<div> 4 </div>
the select divs is the divs the contains 0,2,4 (the first ,third and fifth).
$('div : odd').someFunction(); will select 1,3
and $('div:eq(1)').Somefunction() will select only the div that contain 1 (the second div)
(note: jquery count from 0)

now we finish the first part let's go to the second part which is the functions
$('jqueryReference').function();
the function is can be categorized into 2 category and they are:
1)on what they applied to ?
2)where they come from ?

let begin on the functions
1) on what they applied to ?
the functions is applied on 1 of 2 things html element or document
so when we use $('div') or $('#id') or $('.class') we apply the function to those element's only like( $('#id').show() )
but when we use $.function() we will use a function which not related to a spacial html element (like $.ajax({...}) )

2)where they come from ?
the come from 2 main source the engine or plugin
- the engine is jquery-X.X.X.js which contain the most important function (i.e. ajax....) and u can use them once u include the core libaray
- the plugin is any library the depend on jquery like fancyBox which u can call once u call their library (don't worry most of them are well documented ,tested and have how to use)

finally if u need any thing about JQuery don't worry just call me on the mobile. hahaha i am kidding google it and u will found million of solution.
nothing more to say so have a good day with jquery ;)
More reference =====> http://www.jquery.com
GOOD BYE