73
Beginning

jQuery For Beginners - jQuery Conference 2009

Embed Size (px)

DESCRIPTION

The first part of a three part beginner track, this talk is for the designer/developer that is just starting out with jQuery. Perhaps you’ve heard of jQuery or you’ve used it occasion- ally, this talk will help you understand the core jQuery library.We will:•Cover jQuery’s history •Introduce you to the core team •Explain how jQuery works •Demonstrate how to set-up jQuery •Explore core jQuery methods and structure • Look through a couple of real-world examples

Citation preview

Page 1: jQuery For Beginners - jQuery Conference 2009

Beginning

Page 2: jQuery For Beginners - jQuery Conference 2009

Introduction

Ralph Whitbeck

Senior Web Application Engineer BrandLogic Corporationhttp://brandlogic.com

Blog: http://ralphwhitbeck.com

Twitter: RedWolves

Page 3: jQuery For Beginners - jQuery Conference 2009

Introduction

Tip Jar is open  Tips can be sent via paypal

[email protected]

*Speaker Note*

Pause so audience can write down address

Page 4: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This begins the first part of a three part beginners track

Page 5: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This begins the first part of a three part beginners track

o Beginning jQuery 

Page 6: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This begins the first part of a three part beginners track

o Beginning jQuery

o Extending jQuery - Understanding plugins

Page 7: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This begins the first part of a three part beginners track

o Beginning jQuery

o Extending jQuery - Understanding plugins

o Beginning jQuery UI

Page 8: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

Page 9: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

Page 10: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

• We'll explore jQuery's history

Page 11: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

• We'll explore jQuery's history

• Meet the core team

Page 12: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

• We'll explore jQuery's history

• Meet the core team

• How jQuery works

Page 13: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

• We'll explore jQuery's history

• Meet the core team

• How jQuery works

• Get jQuery on your page

Page 14: jQuery For Beginners - jQuery Conference 2009

Setting Expectations

• This talk is for those just starting out with jQuery

• We'll explore jQuery's history

• Meet the core team

• How jQuery works

• Get jQuery on your page

• Walk through a real-world examples

Page 15: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

Page 16: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• jQuery is JavaScript

Page 17: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• With JavaScript show a hidden element 

if (browserType == "gecko" ) document.poppedLayer =

eval('document.getElementById(”HiddenDIV")'); else if (browserType == "ie")

document.poppedLayer =

eval('document.getElementById(”HiddenDIV")'); else

document.poppedLayer = eval('document.layers[”HiddenDIV"]');

document.poppedLayer.style.visibility = "visible";

Page 18: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• Show a hidden div using jQuery 

$(“#HiddenDIV”).show();

Page 19: jQuery For Beginners - jQuery Conference 2009
Page 20: jQuery For Beginners - jQuery Conference 2009
Page 21: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• jQuery is JavaScript

• It's a light-weight library (19kb minified and GZIPed)

Page 22: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• jQuery is JavaScript

• It's a light-weight library (19kb minified and GZIPed)

• Easy and fast HTML DOM Selection

Page 23: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• jQuery is JavaScript

• It's a light-weight library (19kb minified and GZIPed)

• Easy and fast HTML DOM Selection

• Built to work on all "modern" browsers (IE6+, FF 2.0+, Safari 3.0+, Opera 9+, Chrome 1.0+) 

Page 24: jQuery For Beginners - jQuery Conference 2009

What is jQuery?

• jQuery is JavaScript

• It's a light-weight library (19kb minified and GZIPed)

• Easy and fast HTML DOM Selection

• Built to work on all modern browsers (IE6+, FF 2.0+, Safari 3.0+, Opera 9+, Chrome 1.0+)  

• It's Open Source

Page 25: jQuery For Beginners - jQuery Conference 2009

What can jQuery Produce?

High school students from Spotswood High SchoolJamie GilarJohn Cicolella

Demo’d http://www.jamie.strunex.net/homework/channel/

Page 26: jQuery For Beginners - jQuery Conference 2009

Benefits to jQuery

Page 27: jQuery For Beginners - jQuery Conference 2009

Benefits to jQuery

• Well documented (http://docs.jquery.com)

Page 28: jQuery For Beginners - jQuery Conference 2009

Benefits to jQuery

• Well documented (http://docs.jquery.com)

• Thriving community of developerso Blogs  o Twittero Online Tutorials o Bookso Conferenceso Classes

Page 29: jQuery For Beginners - jQuery Conference 2009

Benefits to jQuery

• jQuery is Extensibleo Create/release your own pluginso Thousands of plugins available

Page 30: jQuery For Beginners - jQuery Conference 2009

Benefits to jQuery

• jQuery is Extensibleo Create/release your own pluginso Thousands of plugins available

• jQuery works with other librarieso Prototypeo Mootools

Page 31: jQuery For Beginners - jQuery Conference 2009

Who is using jQuery?

• Google

• Amazon 

• IBM

• Microsoft 

• Netflix

• Twitter

• Dell, Inc.

• NBC

• EA

• Match

• MLB

• ESPN

• Best Buy

Page 32: jQuery For Beginners - jQuery Conference 2009

jQuery's History

jQuery was released:         January 14, 2006      BarCampNYC 

Page 33: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.0 - August 26, 2006

Page 34: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.0 - August 26, 2006

•  1.1 - January 14, 2007

Page 35: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.0 - August 26, 2006

•  1.1 - January 14, 2007

•  1.1.3 - July 5, 2007

Page 36: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.2 - September 10, 2007

Page 37: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.2 - September 10, 2007

• jQuery UI released - September 16, 2007

Page 38: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  1.2 - September 10, 2007

• jQuery UI released - September 16, 2007

• 1.2.6 - May 24, 2008

Page 39: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  Web site redesign - August 28, 2008

Page 40: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Page 41: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  Web site redesign - August 28, 2008

•  1.3 - January 14, 2009

Page 42: jQuery For Beginners - jQuery Conference 2009

jQuery's History

Versions •  Web site redesign - August 28, 2008

•  1.3 - January 14, 2009

•  1.3.2 - February 20, 2009

Page 43: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

Page 44: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

 Development •  John Resig

•  Brandon Aaron

•  Ariel Flesler

•  Jörn Zaefferer

Page 45: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

 Evangelism •  Rey Bango

•  Karl Swedberg

•  Cody Lindley

Page 46: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

 jQuery UI  •  Paul Bakaus

•  Richard D. Worth

•  Scott González

•  Todd Parker

•  Many others

Page 47: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

Plugins  •  Yehuda Katz

•  Klaus Hartl

•  Mike Alsup 

Page 48: jQuery For Beginners - jQuery Conference 2009

jQuery's Core Team

Web, Design and Infrastructure  •  Scott Jehl

•  Mike Hostetler

•  Jonathan Sharp

Page 49: jQuery For Beginners - jQuery Conference 2009

Setting up jQuery

 

Page 50: jQuery For Beginners - jQuery Conference 2009

Setting up jQuery

Include jQuery on the page 

Page 51: jQuery For Beginners - jQuery Conference 2009

Setting up jQuery

Include jQuery on the page • Download latest from jQuery.com

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>

Page 52: jQuery For Beginners - jQuery Conference 2009

Setting up jQuery

Include jQuery on the page • Download latest from jQuery.com

<script src="jquery-1.3.2.min.js" type="text/javascript></script>

• Include the latest from Google AJAX Libraries API

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

Page 53: jQuery For Beginners - jQuery Conference 2009

Setting up jQuery

Set jQuery to run when the DOM is loaded.     $(document).ready(function(){        //put your jQuery code here.    });

Page 54: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

  $("div").show();

Page 55: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

$

Initiate the jQuery Object

Page 56: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

  jQuery("div").show();

Page 57: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

 ("div")

Select Elements

Page 58: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

 $("div")$("div#intro h2")

$("div.section > p")$("a[href='http://www.jquery.com']")

$("ul#nav li:first")

Page 59: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

 .show()Do Something

Page 60: jQuery For Beginners - jQuery Conference 2009

How jQuery Works

 Demo(Demo based on: http://ejohn.org/apps/learn-jquery/)

Page 61: jQuery For Beginners - jQuery Conference 2009

How jQuery is Structured

• Core 

• Selectors

• Attributes

• Traversing

• Manipulation

• CSS

• Events

• AJAX

• Effects

Page 62: jQuery For Beginners - jQuery Conference 2009

jQuery Core

.each()

.length()

.eq()

.get()

.index()

.data()

.removeData()

...and many more!

Page 63: jQuery For Beginners - jQuery Conference 2009

Selectors

    #id

    element

    .class

    :first

    :last

    :not(selector)

    [attribute=value]    

...and many more!

Page 64: jQuery For Beginners - jQuery Conference 2009

Attributes

    .removeAttr()     .addClass()

    .hasClass()     .removeClass()     .toggleClass()         .html()        .val()

...and many more!

Page 65: jQuery For Beginners - jQuery Conference 2009

Traversing

    .not()     .add()     .children()

    .context()

    .next()

    .prevAll()

    .siblings()

...and many more!

Page 66: jQuery For Beginners - jQuery Conference 2009

Manipulation

    .append()     .after()

    .insertAfter()

    .wrap()

    .replaceWith()

    .empty()

...and many more!

Page 67: jQuery For Beginners - jQuery Conference 2009

CSS

    .width()     .innerHeight()

    .height()

    .outerHeight()

    .offset()

    .position()

    .css()

...and many more!

Page 68: jQuery For Beginners - jQuery Conference 2009

Events

    .ready()     .mouseout()

    .trigger()

    .hover()

    .toggle()

    .blur()

    .live()

...and many more!

Page 69: jQuery For Beginners - jQuery Conference 2009

AJAX

    .ajax()     .load()

    .getJSON()

    .getScript()

    .serialize

    .get()

    .post()

...and many more!

Page 70: jQuery For Beginners - jQuery Conference 2009

Effects

    .hide()       .show()

    .fadeTo()

    .slideToggle()

    .toggle()

    .slideUp()

    .slideDown()

...and many more!

Page 71: jQuery For Beginners - jQuery Conference 2009

Putting it all together

Real-World Demo (Demo based on:

http://ralphwhitbeck.com/2007/11/20/PullingTwitterUpdatesWithJSONAndJQuery.aspx)

Page 72: jQuery For Beginners - jQuery Conference 2009

Thank You

Speaker rate

http://speakerrate.com/talks/1400-beginning-jquery

Page 73: jQuery For Beginners - jQuery Conference 2009

Thank You

Speaker rate

http://speakerrate.com/talks/1400-beginning-jquery