SlideShare a Scribd company logo
1 of 28
Download to read offline
Wat
is
jQuery
en
wat
kun
je
ermee?





                7
mei
2009


          Anne
Jan
Roeleveld

Inhoud


•  Wat
is
jQuery?

•  Waarom
jQuery?

•  Installa?e


•  Voorbeelden

  – Verschillende
func?es/methodes

  – Live
voorbeelden

Wat
is
jQuery?

     Bibliotheek

• 
     Klein
en
snel

• 
     Anima?es

• 
     AJAX

• 
     jQuery
is
gemaakt
om
JS
code
makkelijker
te
maken

• 
     Vereenvoudigt
interac?e
tussen
HTML
en
JavaScript

• 
Voorbeeld

if
(!document.ELEMENT_NODE)
{
                         document._importNode
=
func?on(node,
allChildren)
{

                                                       

switch
(node.nodeType)
{



document.ELEMENT_NODE
=
1;

                                                       



case
document.ELEMENT_NODE:



document.ATTRIBUTE_NODE
=
2;

                                                       





var
newNode
=
document.createElement(node
»



document.TEXT_NODE
=
3;
                             .nodeName);



document.CDATA_SECTION_NODE
=
4;
                    





/*
does
the
node
have
any
alributes
to
add?
*/



document.ENTITY_REFERENCE_NODE
=
5;
                 





if
(node.alributes
&&
node.alributes
»

                                                       .length
>
0)



document.ENTITY_NODE
=
6;

                                                       







for
(var
i
=
0;
il
=
node.alributes.length;
»



document.PROCESSING_INSTRUCTION_NODE
=
7;

                                                       i
<
il)



document.COMMENT_NODE
=
8;

                                                       









newNode.setAlribute(node.alributes
»



document.DOCUMENT_NODE
=
9;
                         .nodeName,
node.getAlribute(node.alributes[i++]
»



document.DOCUMENT_TYPE_NODE
=
10;
                   .nodeName));

                                                       





/*
are
we
going
aser
children
too,
and
does
»



document.DOCUMENT_FRAGMENT_NODE
=
11;

                                                       the
node
have
any?
*/



document.NOTATION_NODE
=
12;

                                                       





if
(allChildren
&&
node.childNodes
&&
»

}

                                                       node.childNodes.length
>
0)

                                                       







for
(var
i
=
0;
il
=
node.childNodes.length;
»

                                                       i
<
il)

                                                       









newNode.appendChild(document._importNode
»

                                                       (node.childNodes[i++],
allChildren));

                                                       





return
newNode;

                                                       





break;

                                                       



case
document.TEXT_NODE:

                                                       



case
document.CDATA_SECTION_NODE:

                                                       



case
document.COMMENT_NODE:

                                                       





return
document.createTextNode(node.nodeValue);

                                                       





break;

                                                       

}

                                                       };





                                               JavaScript

Voorbeeld

$(quot;#contentquot;).load(quot;page.html
#contentquot;);





                jQuery

Voorbeeld

$(quot;#contentquot;).load(quot;page.html
#contentquot;);





                  (!)





                jQuery

Wat
is
jQuery?


•  Selectors

•  Traversing:
DOM
doorlopen

•  Manipula?on:
DOM
veranderen

•  Events

•  Effecten

Waarom
jQuery?

•  Simpele
code


•  Grote
community


•  Plugins


•  Boeken

•  Support


•  Tutorials


•  Open
free
license


•  Snelheid


•  Lichtgewicht
code

Waarom
een
JavaScript
bibliotheek?



•  Schermt
browserverschillen
af

•  Voorkomt
geheugenlekken

•  Geop?maliseerd

•  Goed
onderhouden
door
specialisten

Waarom
jQuery?

Iedereen
gebruikt
het
inmiddels

     Google


• 
     Amazon


• 
     Digg


• 
     Nezlix


• 
     Dell


• 
     HP


• 
     Bank
of
America


• 
     hlp://docs.jquery.com/Sites_Using_jQuery


• 
Installa?e
in
3
stappen

1.
Download

Installa?e
in
3
stappen

1.
Download


2.
Plaats
in
je
website

Installa?e
in
3
stappen

1.
Download


2.
Plaats
in
je
website


3.
Plaats
code

jQuery
selector

•  Zoek
HTML
elementen
met
de
'Selector'


•  $(selector)
‐
gebruik
de
CSS
selector



$(”#myIdquot;)

 
 $(quot;.myClassquot;)


 
 $(quot;tablequot;)

jQuery
selector

•  Zoek
alle
divs
$(quot;divquot;)



<html>


 <body>


 

 <div>jQuery</div>


 

 <div>example</div>


 </body>

</html>

jQuery
selector

•  Zoek
alle
divs
$(quot;divquot;).addClass('foo');



<html>


 <body>


 

 <div
class=quot;fooquot;>jQuery</div>


 

 <div
class=quot;fooquot;>example</div>


 </body>

</html>

Voorbeelden

•  Zoek
HTML
elementen
met
de
'Selector'


•  $(selector)
‐
gebruik
de
CSS
selector



$(quot;myIdquot;)

 
 
 $(quot;.myClassquot;)

 
 
 $(quot;tablequot;)


          $(quot;#myId,
.myClass,
tablequot;)

jQuery
selector

     $(quot;#contentquot;)

 
 
 zoek
element
met
id
content

• 
     


• 
     $(quot;li:firstquot;)

 
 
 
 zoek
het
eerste
list
item

• 
     


• 
     $(quot;tr:oddquot;)


 
 
 zoek
alle
oneven
genummerde
tabelregels

• 
     


• 
     $(quot;a[target=_blank]quot;)

 zoek
alle
links
met
target
blank

• 

•  $(quot;form[id^=step]quot;)

 zoek
alle
forms
waarvan
de
id
begint



 
 
 
 
 
 
 
 met
step


Ga
voor
meer
voorbeelden
van
‘Selectors’
naar


hquot;p://codylindley.com/jqueryselectors/


jQuery
.ready()

$(document).ready(func?on()
{
});


jQuery
script
pas
ac?ef
na
het
volledig
laden
van
de
website

jQuery
methodes

Bewegende
elementen:


before(),
aser(),
appendTo(),
append()



Alributen:


css(),
alr(),
html(),
val(),
addClass()



Effecten:

show(),
fadeOut(),
toggle(),
animate()



Opzoeken
en
volgorde:

find(),
is(),
prevAll(),
next(),
hasClass()



Ajax:


get(),
getJSON(),
post(),
ajax(),
load()

jQuery
methodes

Verplaats
paragraaf
naar
element
met
id
quot;fooquot;



$(quot;pquot;).appendTo(quot;#fooquot;);



<html>


 <body>


 

     <div>jQuery


 

     
    <p>moving</p>


 

     
    <p>paragraphs</p>


 

     </div>


 

     <div
id=quot;fooquot;>


 

     
    example


 

     </div>


 </body>

</html>

jQuery
methodes

Verplaats
paragraaf
naar
element
met
id
quot;fooquot;



$(quot;pquot;).appendTo(quot;#fooquot;);



<html>


 <body>


 

     <div>jQuery</div>


 

     <div
id=quot;foo”>example


 

     
    <p>moving</p>


 

     
    <p>paragraphs</p>


 

     </div>


 </body>

</html>

jQuery
alributen

Voeg
een
zwarte
rand
toe


$(...).css(quot;borderquot;,
quot;1px
solid
blackquot;);



Verander
CSS
styles


$(...).css({
quot;backgroundquot;:
quot;yellowquot;,
quot;heightquot;:
quot;400pxquot;
});



Verander
alle
links
in
google.com


$(quot;aquot;).alr(quot;hrefquot;,
quot;hlp://google.comquot;);

Voorbeelden

•  hlp://www.annejanroeleveld.nl/jquery


Handige
links

     hlp://www.jquery.com


• 
     hlp://docs.jquery.com

• 
     hlp://cli.gs/7D8rum
(51
tutorials)

• 
     hlp://cli.gs/zv82js
(screencast)

• 
     hlp://groups.google.com/group/jquery‐en
(discussie)

• 
     hlp://www.ajaxline.com/20‐best‐jquery‐tutorials‐march‐2009

• 
     hlp://neluts.s3.amazonaws.com/196_jquery/index.htm


• 
     hlp://visualjquery.com/



• 
Boek

Vragen?






Anne
Jan
Roeleveld

hlp://www.annejanroeleveld.nl

hlp://twiler.com/annejan88



More Related Content

What's hot

Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...irwinvifxcfesre
 
For Your Ice Only by Reece Millidge of Damp Gnat
For Your Ice Only by Reece Millidge of Damp GnatFor Your Ice Only by Reece Millidge of Damp Gnat
For Your Ice Only by Reece Millidge of Damp Gnatmochimedia
 
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...sugeladi
 
「レガシーコード」とはいったい?
「レガシーコード」とはいったい?「レガシーコード」とはいったい?
「レガシーコード」とはいったい?Hiroyuki Ohnaka
 
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用Minyi Yan
 
Prestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléPrestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléFondation iFRAP
 
Танки в Лунапарке: нагрузочное тестирование в Яндексе
Танки в Лунапарке: нагрузочное тестирование в ЯндексеТанки в Лунапарке: нагрузочное тестирование в Яндексе
Танки в Лунапарке: нагрузочное тестирование в Яндексеyaevents
 
Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Marco Cedaro
 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for MobileIvano Malavolta
 
Macrovisão do crédito tributário: Aperfeiçoando o Carf
Macrovisão do crédito tributário: Aperfeiçoando o Carf Macrovisão do crédito tributário: Aperfeiçoando o Carf
Macrovisão do crédito tributário: Aperfeiçoando o Carf Roberto Goldstajn
 
Kannada Quran , Chapter 2 , Surah Al Bakhra
Kannada Quran , Chapter 2 , Surah Al BakhraKannada Quran , Chapter 2 , Surah Al Bakhra
Kannada Quran , Chapter 2 , Surah Al BakhraCosmo Homes
 
Kannada Quran- chapter 3- Surah Al imran
Kannada Quran- chapter 3- Surah Al imran Kannada Quran- chapter 3- Surah Al imran
Kannada Quran- chapter 3- Surah Al imran Cosmo Homes
 
Customer Feedback The Next Generation
Customer Feedback   The Next GenerationCustomer Feedback   The Next Generation
Customer Feedback The Next GenerationClicktools
 

What's hot (18)

Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
 
For Your Ice Only by Reece Millidge of Damp Gnat
For Your Ice Only by Reece Millidge of Damp GnatFor Your Ice Only by Reece Millidge of Damp Gnat
For Your Ice Only by Reece Millidge of Damp Gnat
 
The Spread of COVID-19 Disclosure
The Spread of COVID-19 DisclosureThe Spread of COVID-19 Disclosure
The Spread of COVID-19 Disclosure
 
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...
声明 所刊广告,敬请读者进W步核实,如遇商家要求客户交押金或预付款时 ...
 
20091181
2009118120091181
20091181
 
「レガシーコード」とはいったい?
「レガシーコード」とはいったい?「レガシーコード」とはいったい?
「レガシーコード」とはいったい?
 
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用
二维移相光栅光强分布的计算及在制备有序纳米硅阵列中的应用
 
Prestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléPrestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôlé
 
Surah hood
Surah hoodSurah hood
Surah hood
 
Танки в Лунапарке: нагрузочное тестирование в Яндексе
Танки в Лунапарке: нагрузочное тестирование в ЯндексеТанки в Лунапарке: нагрузочное тестирование в Яндексе
Танки в Лунапарке: нагрузочное тестирование в Яндексе
 
Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)
 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for Mobile
 
Android app - Creating Live Wallpaper (tamil)
Android app - Creating Live Wallpaper (tamil)Android app - Creating Live Wallpaper (tamil)
Android app - Creating Live Wallpaper (tamil)
 
Macrovisão do crédito tributário: Aperfeiçoando o Carf
Macrovisão do crédito tributário: Aperfeiçoando o Carf Macrovisão do crédito tributário: Aperfeiçoando o Carf
Macrovisão do crédito tributário: Aperfeiçoando o Carf
 
Kannada Quran , Chapter 2 , Surah Al Bakhra
Kannada Quran , Chapter 2 , Surah Al BakhraKannada Quran , Chapter 2 , Surah Al Bakhra
Kannada Quran , Chapter 2 , Surah Al Bakhra
 
Surah yusuf
Surah yusufSurah yusuf
Surah yusuf
 
Kannada Quran- chapter 3- Surah Al imran
Kannada Quran- chapter 3- Surah Al imran Kannada Quran- chapter 3- Surah Al imran
Kannada Quran- chapter 3- Surah Al imran
 
Customer Feedback The Next Generation
Customer Feedback   The Next GenerationCustomer Feedback   The Next Generation
Customer Feedback The Next Generation
 

Viewers also liked

Asp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxAsp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxRenier Serven
 
Introduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorIntroduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorManoj Kumar
 
ASP.NET MVC Tips, Tricks and Hidden Gems
ASP.NET MVC Tips, Tricks and Hidden GemsASP.NET MVC Tips, Tricks and Hidden Gems
ASP.NET MVC Tips, Tricks and Hidden GemsShay Friedman
 
The Big Comparison of ASP.NET MVC View Engines
The Big Comparison of ASP.NET MVC View EnginesThe Big Comparison of ASP.NET MVC View Engines
The Big Comparison of ASP.NET MVC View EnginesShay Friedman
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo BruggeHTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo BruggePureplexity
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.jsEmanuele DelBono
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentationScott Messinger
 
Getting Started with ASP.NET MVC 3 and Razor
Getting Started with ASP.NET MVC 3 and RazorGetting Started with ASP.NET MVC 3 and Razor
Getting Started with ASP.NET MVC 3 and RazorDan Wahlin
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programminghchen1
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3John Bertucci
 

Viewers also liked (13)

Asp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxAsp.Net MVC - Razor Syntax
Asp.Net MVC - Razor Syntax
 
Introduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with RazorIntroduction to ASP.Net Mvc3 with Razor
Introduction to ASP.Net Mvc3 with Razor
 
ASP.NET MVC Tips, Tricks and Hidden Gems
ASP.NET MVC Tips, Tricks and Hidden GemsASP.NET MVC Tips, Tricks and Hidden Gems
ASP.NET MVC Tips, Tricks and Hidden Gems
 
The Big Comparison of ASP.NET MVC View Engines
The Big Comparison of ASP.NET MVC View EnginesThe Big Comparison of ASP.NET MVC View Engines
The Big Comparison of ASP.NET MVC View Engines
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo BruggeHTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.js
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Getting Started with ASP.NET MVC 3 and Razor
Getting Started with ASP.NET MVC 3 and RazorGetting Started with ASP.NET MVC 3 and Razor
Getting Started with ASP.NET MVC 3 and Razor
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

jQuery in 10 minuten