jQuery
JavaScript Made Easy
jQuery
in
the
Wild
• Bank
of
America        • Trac
• Intuit
                • mozdev
• Google                 • Drupal
• NBC                    • PEAR
• Slashdot               • Zend
Framework
• Sourceforge            • WordPress
                         • SPIP
• Warner
Bros.
Records
                         • Symfony
• Newsweek
jQuery
Benefits
• From
beginner
to
advanced
• At
its
core,
a
simple
concept
• Unobtrusive
from
the
ground
up
• Small
file
size(s)
• Easy
Plugin
API
• Excellent
documentaRon
• Thriving,
Smart,
Helpful
Community
Find
Something,

              Do
Something
• $(‘tbody
tr:nth‐child(even)’)
  .addClass(‘alt’);


Unobtrusive
Behavior       Content     Presentation


jquery.js     index.html     style.css



custom.js
Designerly
Syntax
• CSS                    • jQuery

 p
{
}                    $(‘p’)

 .menu
{
}                $(‘.menu’)

 #content
{
}             $(‘#content’)
Designerly
Syntax
• CSS                     • jQuery

 a[rel=nofollow]           $(‘a[rel=nofollow]’)

 #content
>
p
{
}          $(‘#content
>
p’)

 tr:nth‐child(even)
{
}    $(‘tr:nth‐child(even)’)

Example
• Get
the
height
of
the
viewport…
DOM
ScripRng
var x,y;
if (self.innerHeight) { // all except Explorer
  x = self.innerWidth;
  y = self.innerHeight;
}
else if (document.documentElement &&
  document.documentElement.clientHeight) {
   // Explorer 6 Strict Mode
  x = document.documentElement.clientWidth;
  y = document.documentElement.clientHeight;
}
else if (document.body) { // other Explorers
  x = document.body.clientWidth;
  y = document.body.clientHeight;
}
jQuery
var x = $(window).width();
var y = $(window).height();
Example
• Find
a
blockquote
with
a
cite
adribute
 <blockquote
cite=“hdp://cnn.com”>
…
• Create
a
link
to
the
URL
of
the
cite
adribute

  
<a
href=“hdp://cnn.com”>source</a>
• Place
the
link
in
a
new
paragraph
at
the
end

  of
the
blockquote.
DOM
ScripRng
if (!document.getElementsByTagName) return false;
var quotes = document.getElementsByTagName("blockquote");
for (var i=0; i<quotes.length; i++) {
  var source = quotes[i].getAttribute("cite");
  if (source) {
    var link = document.createElement("a");
    link.setAttribute("href",source);
    var text = document.createTextNode("source");
    link.appendChild(text);
    var para = document.createElement("p");
    para.className = "attribution";
    para.appendChild(link);
    quotes[i].appendChild(para);
  }
}
jQuery
$('blockquote[cite]').each(function() {
  $('<p class="attribution"></p>')
    .append('<a href="' + $(this).attr('cite') + '">source</a>')
    .appendTo($(this));
});
Gekng
Started
• Referencing
Scripts
in
HTML
• Document
Ready
Referencing
Scripts
                in
the
<head>
  • Typical
setup
  • jQuery
file
goes
first



<head>
<!-- stuff -->
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"
  type="text/javascript"></script>
<script src="custom.js" type="text/javascript"></script>
<!-- more stuff -->
</head>
Document
Ready
• Binds
a
funcRon
to
be
executed
as
soon
as
the
DOM

  has
been
successfully
loaded...
• Before
images
load
• A.er
stylesheets
load
(for
now)
• Usually
beder
than
window.onload
Document
Ready:
               Code

$(document).ready(function() {
      // Stuff to do as soon as the DOM is ready;
});
Document
Ready:
             VarieRes
• $(document).ready(function() {/* */});

• $().ready(function() {/* */});

• $(function() {/* */});

• jQuery(function($) {/* /*});
Document
Ready:
 • MulRple
document
ready
funcRons
are
fine.
 • Scope
may
be
an
issue.
$(document).ready(function() {
     var mood = ‘happy’;
});

$(document).ready(function() {
     try {
           alert(mood); // no alert
     } catch(err) {
           alert(err); // "ReferenceError: mood is not

      defined"
      }
});
Document
Ready:
 • MulRple
document
ready
funcRons
are
fine.
 • Scope
may
be
an
issue.

$(document).ready(function() {
     var $.mood = ‘happy’;
});

$(document).ready(function() {
     try {
           alert($.mood); // "happy"
     } catch(err) {
           alert(err); // no alert
     }
});
Document
Ready:

    • When
<script>
is
inside
<body>
(someRmes)


<body>
<!-- more stuff -->
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
    // no document ready here
</script>
</body>
Document
Ready
                  When
Not
to
Use
   • When
images
need
to
be
loaded
first


$(window).bind('load', function() {
     // do something with images
}
DocumentaRon
• Official
DocumentaRon        • Books
  – API:
docs.jquery.com       – Learning
jQuery
  – FAQ                        – jQuery
in
AcRon
  – Tutorials
                               – more
in
the
works
• Tutorial
Sites
  – learningjquery.com
  – jqueryminute.com
  – jqueryfordesigners.com
  – many
more!
The
Community
• jQuery
“evangelism”
• Google
Groups
  – jquery‐en
  – jquery‐dev
  – jquery‐ui
• planet.jquery.com
• IRC
  – freenode.net
#jquery
• Twider
  – @jquery,
@jquery‐ui

More Related Content

PDF
State of jQuery and Drupal
PDF
Introduction to jQuery (Ajax Exp 2007)
PDF
JavaScript Library Overview (Ajax Exp West 2007)
PDF
Advanced jQuery (Ajax Exp 2007)
PPT
A Short Introduction To jQuery
PDF
jQuery Loves Developers - Oredev 2009
PDF
D3.js and SVG
PDF
jQuery Essentials
State of jQuery and Drupal
Introduction to jQuery (Ajax Exp 2007)
JavaScript Library Overview (Ajax Exp West 2007)
Advanced jQuery (Ajax Exp 2007)
A Short Introduction To jQuery
jQuery Loves Developers - Oredev 2009
D3.js and SVG
jQuery Essentials

What's hot (19)

ODP
Introduction to jQuery
PDF
Introduction to jQuery (Ajax Exp 2006)
PPT
JQuery introduction
PDF
Prototype & jQuery
PPT
jQuery Learning
PDF
jQuery Introduction
PDF
Web2.0 with jQuery in English
KEY
Week 4 - jQuery + Ajax
PDF
jQuery Features to Avoid
PPTX
Unobtrusive javascript with jQuery
PDF
Stack Overflow Austin - jQuery for Developers
PDF
Learning jQuery in 30 minutes
PPTX
jQuery Best Practice
ODP
Drupal Best Practices
PPTX
JavaScript!
KEY
Dojo, from scratch to result
PPTX
How dojo works
PPT
PPTX
jQuery from the very beginning
Introduction to jQuery
Introduction to jQuery (Ajax Exp 2006)
JQuery introduction
Prototype & jQuery
jQuery Learning
jQuery Introduction
Web2.0 with jQuery in English
Week 4 - jQuery + Ajax
jQuery Features to Avoid
Unobtrusive javascript with jQuery
Stack Overflow Austin - jQuery for Developers
Learning jQuery in 30 minutes
jQuery Best Practice
Drupal Best Practices
JavaScript!
Dojo, from scratch to result
How dojo works
jQuery from the very beginning
Ad

Viewers also liked (7)

PDF
annotation_tutorial_2008
PDF
phpTutorial1
PDF
flash-flv
PDF
presentation
PDF
collapsible-panels-tutorial
PDF
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
PDF
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
annotation_tutorial_2008
phpTutorial1
flash-flv
presentation
collapsible-panels-tutorial
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
Ad

Similar to bcgr3-jquery (20)

PDF
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
PPTX
Jquery fundamentals
PPTX
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
PPTX
Jquery
PPTX
SPTechCon DevDays - SharePoint & jQuery
PPTX
SharePoint and jQuery Essentials
PPTX
Learning About JavaScript (…and its little buddy, JQuery!)
PPTX
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
PPTX
SharePoint & jQuery Guide - SPSNashville 2014
PDF
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
PPTX
SharePoint Cincy 2012 - jQuery essentials
PDF
Learning jQuery made exciting in an interactive session by one of our team me...
PDF
fuser interface-development-using-jquery
KEY
User Interface Development with jQuery
PDF
JavaScript DOM & event
PPT
J query module1
PDF
Short intro to JQuery and Modernizr
PPTX
JavaScript performance patterns
PPTX
SEF2013 - A jQuery Primer for SharePoint
PDF
jQuery for beginners
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Jquery fundamentals
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
Jquery
SPTechCon DevDays - SharePoint & jQuery
SharePoint and jQuery Essentials
Learning About JavaScript (…and its little buddy, JQuery!)
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SharePoint & jQuery Guide - SPSNashville 2014
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
SharePoint Cincy 2012 - jQuery essentials
Learning jQuery made exciting in an interactive session by one of our team me...
fuser interface-development-using-jquery
User Interface Development with jQuery
JavaScript DOM & event
J query module1
Short intro to JQuery and Modernizr
JavaScript performance patterns
SEF2013 - A jQuery Primer for SharePoint
jQuery for beginners

More from tutorialsruby (20)

PDF
&lt;img src="../i/r_14.png" />
PDF
&lt;img src="../i/r_14.png" />
PDF
&lt;img src="../i/r_14.png" />
PDF
Standardization and Knowledge Transfer – INS0
PDF
xhtml_basics
PDF
xhtml_basics
PDF
xhtml-documentation
PDF
xhtml-documentation
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
HowTo_CSS
PDF
HowTo_CSS
PDF
BloggingWithStyle_2008
PDF
BloggingWithStyle_2008
PDF
cascadingstylesheets
PDF
cascadingstylesheets
PDF
Winter%200405%20-%20Advanced%20Javascript
PDF
Winter%200405%20-%20Advanced%20Javascript
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
Standardization and Knowledge Transfer – INS0
xhtml_basics
xhtml_basics
xhtml-documentation
xhtml-documentation
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
HowTo_CSS
HowTo_CSS
BloggingWithStyle_2008
BloggingWithStyle_2008
cascadingstylesheets
cascadingstylesheets
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript

Recently uploaded (20)

PPT
What is a Computer? Input Devices /output devices
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Unlock new opportunities with location data.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Architecture types and enterprise applications.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
The various Industrial Revolutions .pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Getting Started with Data Integration: FME Form 101
PPT
Geologic Time for studying geology for geologist
What is a Computer? Input Devices /output devices
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
O2C Customer Invoices to Receipt V15A.pptx
DP Operators-handbook-extract for the Mautical Institute
Unlock new opportunities with location data.pdf
Enhancing emotion recognition model for a student engagement use case through...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A novel scalable deep ensemble learning framework for big data classification...
Architecture types and enterprise applications.pdf
Tartificialntelligence_presentation.pptx
WOOl fibre morphology and structure.pdf for textiles
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
The various Industrial Revolutions .pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Taming the Chaos: How to Turn Unstructured Data into Decisions
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Benefits of Physical activity for teenagers.pptx
NewMind AI Weekly Chronicles – August ’25 Week III
Getting Started with Data Integration: FME Form 101
Geologic Time for studying geology for geologist

bcgr3-jquery