jquery - write less, do more javascript toolkit

56
Introduction to jQuery Write less, do more! Girish Venkatachalam Chennai [email protected] December 8, 2007

Upload: girish-venkatachalam

Post on 17-May-2015

7.364 views

Category:

Business


1 download

Tags:

DESCRIPTION

jQuery is a fantastic toolkit for web development. I go over the basics of web development and how one has to about learning the basics of jQuery

TRANSCRIPT

Page 1: jQuery - write less, do more javascript toolkit

Introduction to jQueryWrite less, do more!

Girish Venkatachalam

Chennai

[email protected]

December 8, 2007

Page 2: jQuery - write less, do more javascript toolkit

Basic web interface architecture

Figure: basic building blocks

HTML provides content

CSS provides appearance, placement and layout

Javascript provides dynamism and defines behavior

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 2 / 22

Page 3: jQuery - write less, do more javascript toolkit

Basic web interface architecture

Figure: basic building blocks

HTML provides content

CSS provides appearance, placement and layout

Javascript provides dynamism and defines behavior

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 2 / 22

Page 4: jQuery - write less, do more javascript toolkit

Basic web interface architecture

Figure: basic building blocks

HTML provides content

CSS provides appearance, placement and layout

Javascript provides dynamism and defines behavior

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 2 / 22

Page 5: jQuery - write less, do more javascript toolkit

html tree structure

Every html node forms part of a tree with 〈html〉 as root node

You can traverse the tree easily since it has a fixed structure

Every node has attributes and optionally child nodes

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 3 / 22

Page 6: jQuery - write less, do more javascript toolkit

html tree structure

Every html node forms part of a tree with 〈html〉 as root node

You can traverse the tree easily since it has a fixed structure

Every node has attributes and optionally child nodes

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 3 / 22

Page 7: jQuery - write less, do more javascript toolkit

html tree structure

Every html node forms part of a tree with 〈html〉 as root node

You can traverse the tree easily since it has a fixed structure

Every node has attributes and optionally child nodes

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 3 / 22

Page 8: jQuery - write less, do more javascript toolkit

A simple html example

<html>

<head>

<title> A simple example </title>

</head>

<body>

<h1 align="center"> Hello world html </h1>

<p> How are you? </p>

</body>

</html>

Fundamental building block of all web apps

Javascript to manipulate DOM elementsCascading style sheets (CSS) for appearance

Learning html is a must before we do web programming!

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 5 / 22

Page 9: jQuery - write less, do more javascript toolkit

A simple html example

<html>

<head>

<title> A simple example </title>

</head>

<body>

<h1 align="center"> Hello world html </h1>

<p> How are you? </p>

</body>

</html>

Fundamental building block of all web appsJavascript to manipulate DOM elements

Cascading style sheets (CSS) for appearance

Learning html is a must before we do web programming!

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 5 / 22

Page 10: jQuery - write less, do more javascript toolkit

A simple html example

<html>

<head>

<title> A simple example </title>

</head>

<body>

<h1 align="center"> Hello world html </h1>

<p> How are you? </p>

</body>

</html>

Fundamental building block of all web appsJavascript to manipulate DOM elementsCascading style sheets (CSS) for appearance

Learning html is a must before we do web programming!

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 5 / 22

Page 11: jQuery - write less, do more javascript toolkit

A simple html example

<html>

<head>

<title> A simple example </title>

</head>

<body>

<h1 align="center"> Hello world html </h1>

<p> How are you? </p>

</body>

</html>

Fundamental building block of all web appsJavascript to manipulate DOM elementsCascading style sheets (CSS) for appearance

Learning html is a must before we do web programming!

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 5 / 22

Page 12: jQuery - write less, do more javascript toolkit

What is CSS?

html supplies the content

CSS determines the beauty

What remains?

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 6 / 22

Page 13: jQuery - write less, do more javascript toolkit

What is CSS?

html supplies the content

CSS determines the beauty

What remains?

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 6 / 22

Page 14: jQuery - write less, do more javascript toolkit

What is CSS?

html supplies the content

CSS determines the beauty

What remains?

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 6 / 22

Page 15: jQuery - write less, do more javascript toolkit

Intro to javascript

What about the behavior?

That is where a programming language like javascript comes in.

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 7 / 22

Page 16: jQuery - write less, do more javascript toolkit

Intro to javascript

What about the behavior?

That is where a programming language like javascript comes in.

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 7 / 22

Page 17: jQuery - write less, do more javascript toolkit

Document Object Model

What is the role of DOM in web programming?

Animations

jQuery does a marvelous job of DOM manipulations

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 8 / 22

Page 18: jQuery - write less, do more javascript toolkit

Document Object Model

What is the role of DOM in web programming?

Animations

jQuery does a marvelous job of DOM manipulations

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 8 / 22

Page 19: jQuery - write less, do more javascript toolkit

jQuery fundament

Tiniest js/AJAX toolkit around

Very very very powerful

Extremely well maintained with 100s of plugins

Abstracts out portability issues and javascript gunk

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 9 / 22

Page 20: jQuery - write less, do more javascript toolkit

jQuery fundament

Tiniest js/AJAX toolkit around

Very very very powerful

Extremely well maintained with 100s of plugins

Abstracts out portability issues and javascript gunk

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 9 / 22

Page 21: jQuery - write less, do more javascript toolkit

jQuery fundament

Tiniest js/AJAX toolkit around

Very very very powerful

Extremely well maintained with 100s of plugins

Abstracts out portability issues and javascript gunk

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 9 / 22

Page 22: jQuery - write less, do more javascript toolkit

jQuery fundament

Tiniest js/AJAX toolkit around

Very very very powerful

Extremely well maintained with 100s of plugins

Abstracts out portability issues and javascript gunk

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 9 / 22

Page 23: jQuery - write less, do more javascript toolkit

A jQuery code sample

$(document).ready(function() {

$(’a’).hover(function() {

$(this).hide(’slow’);

});

});

Neat eh?

This is all it takes for an animation using jQuery

You have to add it between the ’script’ tag you always use forjavascript

After all jQuery is also javascript

Without its disadvantages and ugliness. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 11 / 22

Page 24: jQuery - write less, do more javascript toolkit

A jQuery code sample

$(document).ready(function() {

$(’a’).hover(function() {

$(this).hide(’slow’);

});

});

Neat eh?

This is all it takes for an animation using jQuery

You have to add it between the ’script’ tag you always use forjavascript

After all jQuery is also javascript

Without its disadvantages and ugliness. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 11 / 22

Page 25: jQuery - write less, do more javascript toolkit

A jQuery code sample

$(document).ready(function() {

$(’a’).hover(function() {

$(this).hide(’slow’);

});

});

Neat eh?

This is all it takes for an animation using jQuery

You have to add it between the ’script’ tag you always use forjavascript

After all jQuery is also javascript

Without its disadvantages and ugliness. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 11 / 22

Page 26: jQuery - write less, do more javascript toolkit

A jQuery code sample

$(document).ready(function() {

$(’a’).hover(function() {

$(this).hide(’slow’);

});

});

Neat eh?

This is all it takes for an animation using jQuery

You have to add it between the ’script’ tag you always use forjavascript

After all jQuery is also javascript

Without its disadvantages and ugliness. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 11 / 22

Page 27: jQuery - write less, do more javascript toolkit

A jQuery code sample

$(document).ready(function() {

$(’a’).hover(function() {

$(this).hide(’slow’);

});

});

Neat eh?

This is all it takes for an animation using jQuery

You have to add it between the ’script’ tag you always use forjavascript

After all jQuery is also javascript

Without its disadvantages and ugliness. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 11 / 22

Page 28: jQuery - write less, do more javascript toolkit

Another jQuery sample

$(document).ready(function (){

$(’a’).hover(function (){

$(this).hide(’slow’);

},function(){

$(this).show(’fast’);

});

});

This sample builds on the previous example

This is all it takes for an animation using jQuery (once again)

But it is not just animations. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 13 / 22

Page 29: jQuery - write less, do more javascript toolkit

Another jQuery sample

$(document).ready(function (){

$(’a’).hover(function (){

$(this).hide(’slow’);

},function(){

$(this).show(’fast’);

});

});

This sample builds on the previous example

This is all it takes for an animation using jQuery (once again)

But it is not just animations. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 13 / 22

Page 30: jQuery - write less, do more javascript toolkit

Another jQuery sample

$(document).ready(function (){

$(’a’).hover(function (){

$(this).hide(’slow’);

},function(){

$(this).show(’fast’);

});

});

This sample builds on the previous example

This is all it takes for an animation using jQuery (once again)

But it is not just animations. . .

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 13 / 22

Page 31: jQuery - write less, do more javascript toolkit

Exploring jQuery

jQuery’s power comes from its powerful selectors, easy DOM andCSS manipulations, mouse and keyboard event handling and excellentsupport for AJAX programming.

John Resig achieved something revolutionary by leaving out theinessentials and keeping things small

This has led to a subculture of jQuery plugins - extensions areavailable for nearly every web design task you can think of

We shall take a peek at some of the extensions

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 14 / 22

Page 32: jQuery - write less, do more javascript toolkit

Exploring jQuery

jQuery’s power comes from its powerful selectors, easy DOM andCSS manipulations, mouse and keyboard event handling and excellentsupport for AJAX programming.

John Resig achieved something revolutionary by leaving out theinessentials and keeping things small

This has led to a subculture of jQuery plugins - extensions areavailable for nearly every web design task you can think of

We shall take a peek at some of the extensions

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 14 / 22

Page 33: jQuery - write less, do more javascript toolkit

Exploring jQuery

jQuery’s power comes from its powerful selectors, easy DOM andCSS manipulations, mouse and keyboard event handling and excellentsupport for AJAX programming.

John Resig achieved something revolutionary by leaving out theinessentials and keeping things small

This has led to a subculture of jQuery plugins - extensions areavailable for nearly every web design task you can think of

We shall take a peek at some of the extensions

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 14 / 22

Page 34: jQuery - write less, do more javascript toolkit

Exploring jQuery

jQuery’s power comes from its powerful selectors, easy DOM andCSS manipulations, mouse and keyboard event handling and excellentsupport for AJAX programming.

John Resig achieved something revolutionary by leaving out theinessentials and keeping things small

This has led to a subculture of jQuery plugins - extensions areavailable for nearly every web design task you can think of

We shall take a peek at some of the extensions

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 14 / 22

Page 35: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 36: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 37: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 38: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 39: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 40: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 41: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 42: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 43: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 44: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 45: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 46: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 47: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 48: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 49: jQuery - write less, do more javascript toolkit

jQuery plugins

jScrollPane

Field plugin

Extra selectors

Visual jQuery

Cycle plugin

jqPuzzle

jTip for balloon tips (tooltip)

Impromptu

Embed videos (You canwatch mpeg videos )

Datepicker plugin

UI for drag and drop

Confirm plugin

Form handing

Keyboard shortcut handling

And much much more...

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 15 / 22

Page 50: jQuery - write less, do more javascript toolkit

Advanced jQuery I

jQuery can work with AJAX and other javascript libraries seamlessly

jQuery can obviate the need for using javascript directly for mostcommon web app/UI development needs.

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 16 / 22

Page 51: jQuery - write less, do more javascript toolkit

Advanced jQuery I

jQuery can work with AJAX and other javascript libraries seamlessly

jQuery can obviate the need for using javascript directly for mostcommon web app/UI development needs.

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 16 / 22

Page 52: jQuery - write less, do more javascript toolkit

Advanced jQuery I

jQuery can work with AJAX and other javascript libraries seamlessly

jQuery can obviate the need for using javascript directly for mostcommon web app/UI development needs.

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 16 / 22

Page 53: jQuery - write less, do more javascript toolkit

Advanced jQuery II

$(document).ready(function() {

$("#rating").append("Please rate: ");

for ( var i = 1; i <= 5; i++ )

$("#rating").append("<a href=’#’>" + i + "</a> ");

$("#rating a").click(function(e){

$.post("rate.php", {rating: $(this).html()},

function(xml) { $("#rating").html(

"Thanks for rating, current average: " +

$("average", xml).text() +

", number of votes: " +

$("count", xml).text()

); });

return false; }); });

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 18 / 22

Page 54: jQuery - write less, do more javascript toolkit

Further study

More selectors and advanced use is gained by experience

$(’#fooid’).onblur();

$(’.fooclass’).onmousever();

$(’div#fooid’).find();

$(’h1’).css(’text-transform’,’underline’);

$(’div’).addClass(’colorful’);

Possibilities are endless!

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 20 / 22

Page 55: jQuery - write less, do more javascript toolkit

Further study

More selectors and advanced use is gained by experience

$(’#fooid’).onblur();

$(’.fooclass’).onmousever();

$(’div#fooid’).find();

$(’h1’).css(’text-transform’,’underline’);

$(’div’).addClass(’colorful’);

Possibilities are endless!Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 20 / 22

Page 56: jQuery - write less, do more javascript toolkit

Questions?

Discussion and questions?1 http://jquery.com

2 http://visualjquery.com

3 http://www.alistapart.com

4 http://www.csszengarden.com

Girish Venkatachalam (entrepreneur) Introduction to jQuery December 8, 2007 22 / 22