SlideShare a Scribd company logo
jQueryjQuery
The Way to JavaScript and RichThe Way to JavaScript and Rich
Internet ApplicationsInternet Applications
Introduction to jQueryIntroduction to jQuery
• Developed by John Resig at Rochester Institute of TechnologyDeveloped by John Resig at Rochester Institute of Technology
• ““jQueryjQuery is a lightweightis a lightweight JavaScript libraryJavaScript library that emphasizesthat emphasizes
interaction betweeninteraction between JavaScriptJavaScript andand HTMLHTML. It was released in. It was released in
January 2006 atJanuary 2006 at BarCampBarCamp NYC byNYC by John ResigJohn Resig.”.”
• ““jQuery isjQuery is free, open source softwarefree, open source software Dual-licensedDual-licensed under theunder the
MIT LicenseMIT License and theand the GNU General Public LicenseGNU General Public License.”.”
• ““It’s all about simplicity. Why should web developers be forced toIt’s all about simplicity. Why should web developers be forced to
write long, complex, book-length pieces of code when they want towrite long, complex, book-length pieces of code when they want to
create simple pieces of interaction?”create simple pieces of interaction?”
• Current version is 1.3.2.Current version is 1.3.2.
• Version 1.4 due out soon.Version 1.4 due out soon.
John ResigJohn Resig
• John Resig is a JavaScript Tool DeveloperJohn Resig is a JavaScript Tool Developer
for thefor the Mozilla CorporationMozilla Corporation and the authorand the author
of the bookof the book Pro JavaScript TechniquesPro JavaScript Techniques..
He's also the creator and lead developer ofHe's also the creator and lead developer of
thethe jQuery JavaScript libraryjQuery JavaScript library..
• Currently, John is located in Boston, MA.Currently, John is located in Boston, MA.
He's hard at work on his second book,He's hard at work on his second book,
Secrets of the JavaScript NinjaSecrets of the JavaScript Ninja, due in, due in
bookstores in 2009.bookstores in 2009.
• MicrosoftMicrosoft andand NokiaNokia have announcedhave announced
plans to bundle jQuery on their platforms,plans to bundle jQuery on their platforms,
[1][1] Microsoft adopting it initially withinMicrosoft adopting it initially within
Visual StudioVisual Studio[2][2] for use within Microsoft'sfor use within Microsoft's
ASP.NET AJAXASP.NET AJAX framework andframework and
ASP.NET MVC FrameworkASP.NET MVC Framework whilst Nokiawhilst Nokia
will integrate it into their Web Run-Timewill integrate it into their Web Run-Time
platform.platform.
Introduction to jQueryIntroduction to jQuery
• Why do I want itWhy do I want it
– Rich Internet Applications (RIA)Rich Internet Applications (RIA)
– Dynamic HTML (DHTML)Dynamic HTML (DHTML)
• How do I get itHow do I get it
– www.jquery.comwww.jquery.com
• How can I learn itHow can I learn it
– jQuery in ActionjQuery in Action by Bibeault & Katz, Manningby Bibeault & Katz, Manning
– jQuery Visual Quickstart GuidejQuery Visual Quickstart Guide by Holzner, Peachpitby Holzner, Peachpit
– www.jquery.comwww.jquery.com
– docs.jquery.comdocs.jquery.com
– www.visualjquery.comwww.visualjquery.com
– www.Jqueryfordesigners.comwww.Jqueryfordesigners.com
– www.gscottolson.com/weblog/ - cheat sheetwww.gscottolson.com/weblog/ - cheat sheet
– www.javascripttoolbox.com/jquerywww.javascripttoolbox.com/jquery
Plan for the 4 sessionsPlan for the 4 sessions
• Class I – Introduction, installation, “HowdyClass I – Introduction, installation, “Howdy
World”, Ready function, DOM, SelectingWorld”, Ready function, DOM, Selecting
and Formatting web page elementsand Formatting web page elements
• Class II – Events and AnimationsClass II – Events and Animations
• Class III – jQuery Plugin librariesClass III – jQuery Plugin libraries
• Class IV – AJAX with PHP and ASP.NETClass IV – AJAX with PHP and ASP.NET
Introduction to jQueryIntroduction to jQuery
• Installation – You just download theInstallation – You just download the
jquery-1.3.2.js file and put it in yourjquery-1.3.2.js file and put it in your
website folderwebsite folder
– Can access via URLCan access via URL
What jQuery DoesWhat jQuery Does
• ““Unobtrusive” JavaScript – separation ofUnobtrusive” JavaScript – separation of
behaviorbehavior from structurefrom structure
• CSS – separation ofCSS – separation of stylestyle from structurefrom structure
• Allows adding JavaScript to your web pagesAllows adding JavaScript to your web pages
• Advantages overAdvantages over justjust JavaScriptJavaScript
– Much easier to useMuch easier to use
– Eliminates cross-browser problemsEliminates cross-browser problems
• HTML to CSS to DHTMLHTML to CSS to DHTML
5 Things jQuery Provides5 Things jQuery Provides
• Select DOM (Document Object Model) elementsSelect DOM (Document Object Model) elements
on a page – one element or a group of themon a page – one element or a group of them
• Set properties of DOM elements, in groupsSet properties of DOM elements, in groups
(“Find something, do something with it”)(“Find something, do something with it”)
• Creates, deletes, shows, hides DOM elementsCreates, deletes, shows, hides DOM elements
• Defines event behavior on a page (click, mouseDefines event behavior on a page (click, mouse
movement, dynamic styles, animations, dynamicmovement, dynamic styles, animations, dynamic
content)content)
• AJAX callsAJAX calls
The DOMThe DOM
• Document Object ModelDocument Object Model
• jQuery is “DOM scripting”jQuery is “DOM scripting”
• Heirarchal structure of a web pageHeirarchal structure of a web page
• You can add and subtract DOM elementsYou can add and subtract DOM elements
on the flyon the fly
• You can change the properties andYou can change the properties and
contents of DOM elements on the flycontents of DOM elements on the fly
The DOMThe DOM
• ““TheThe Document Object ModelDocument Object Model ((DOMDOM) is a cross-platform and) is a cross-platform and
language-independent convention for representing and interactinglanguage-independent convention for representing and interacting
with objects in HTML, XHTML and XML documents. Aspects of thewith objects in HTML, XHTML and XML documents. Aspects of the
DOM (such as its "Elements") may be addressed and manipulatedDOM (such as its "Elements") may be addressed and manipulated
within the syntax of the programming language in use.” Wikipediawithin the syntax of the programming language in use.” Wikipedia
The jQuery FunctionThe jQuery Function
• jQuery() = $()jQuery() = $()
• $(function)$(function) The “Ready” handlerThe “Ready” handler
• $(‘selector’)$(‘selector’) Element selector expressionElement selector expression
• $(element)$(element) Specify element(s) directlySpecify element(s) directly
• $(‘HTML’)$(‘HTML’) HTML creationHTML creation
• $.function()$.function() Execute a jQuery functionExecute a jQuery function
• $.fn.myfunc(){}$.fn.myfunc(){} Create jQuery functionCreate jQuery function
Tutorial 1 – The Ready FunctionTutorial 1 – The Ready Function
• Set up a basic HTML page and add jQuerySet up a basic HTML page and add jQuery
• Create a “ready” functionCreate a “ready” function
• Call a functionCall a function
• 5 ways to specify the ready function5 ways to specify the ready function
– jquery(document).ready(function(){…};);jquery(document).ready(function(){…};);
– jquery().ready(function(){…};)jquery().ready(function(){…};)
– jquery(function(){…};)jquery(function(){…};)
– jquery(dofunc);jquery(dofunc);
– $(dofunc);$(dofunc);
Tutorial 2 – Selecting ElementsTutorial 2 – Selecting Elements
Creating a “wrapped set”Creating a “wrapped set”
• $(selector)$(selector)
• selector:selector:
– $(‘#id’)$(‘#id’) id of elementid of element
– $(‘p’)$(‘p’) tag nametag name
– $(‘.class’)$(‘.class’) CSS classCSS class
– $(‘p.class’)$(‘p.class’) <p> elements having the CSS class<p> elements having the CSS class
– $(‘p:first’)$(‘p:first’) $(‘p:last’)$(‘p:last’) $(‘p:odd’)$(‘p:odd’) $(‘p:even’)$(‘p:even’)
– $(‘p:eq(2)’)$(‘p:eq(2)’) gets the 2gets the 2ndnd
<p> element (1 based)<p> element (1 based)
– $(‘p’)[1]$(‘p’)[1] gets the 2gets the 2ndnd
<p> element (0 based)<p> element (0 based)
– $(‘p:nth-child(3))$(‘p:nth-child(3)) gets the 3gets the 3rdrd
<p> element of the parent. n=even, odd too.<p> element of the parent. n=even, odd too.
– $(‘p:nth-child(5n+1)’)$(‘p:nth-child(5n+1)’) gets the 1gets the 1stst
element after every 5th oneelement after every 5th one
– $(‘p a’)$(‘p a’) <a> elements, descended from a <p><a> elements, descended from a <p>
– $(‘p>a’)$(‘p>a’) <a> elements, direct child of a <p><a> elements, direct child of a <p>
– $(‘p+a’)$(‘p+a’) <a> elements, directly following a <p><a> elements, directly following a <p>
– $(‘p, a’)$(‘p, a’) <p> and <a> elements<p> and <a> elements
– $(‘li:has(ul)’)$(‘li:has(ul)’) <li> elements that have at least one <ul> descendent<li> elements that have at least one <ul> descendent
– $(‘:not(p)’)$(‘:not(p)’) all elements but <p> elementsall elements but <p> elements
– $(‘p:hidden’)$(‘p:hidden’) only <p> elements that are hiddenonly <p> elements that are hidden
– $(‘p:empty’)$(‘p:empty’) <p> elements that have no child elements<p> elements that have no child elements
Selecting Elements, cont.Selecting Elements, cont.
• $(‘img’[alt])$(‘img’[alt]) <img> elements having an alt attribute<img> elements having an alt attribute
• $(‘a’[href^=http://])$(‘a’[href^=http://]) <a> elements with an href attribute<a> elements with an href attribute
starting with ‘http://’starting with ‘http://’
• $(‘a’[href$=.pdf])$(‘a’[href$=.pdf]) <a> elements with an href attribute<a> elements with an href attribute
ending with ‘.pdf’ending with ‘.pdf’
• $(‘a’[href*=ntpcug])$(‘a’[href*=ntpcug]) <a> elements with an href attriute<a> elements with an href attriute
containing ‘ntpcug’containing ‘ntpcug’
Useful jQuery FunctionsUseful jQuery Functions
• .each().each() iterate over the setiterate over the set
• .size().size() number of elements in setnumber of elements in set
• .end().end() reverts to the previous setreverts to the previous set
• .get(n).get(n) get just the nth element (0 based)get just the nth element (0 based)
• .eq(n).eq(n) get just the nth element (0 based) also .lt(n) & .gt(n)get just the nth element (0 based) also .lt(n) & .gt(n)
• .slice(n,m).slice(n,m) gets only nth to (m-1)th elementsgets only nth to (m-1)th elements
• .not(‘p’).not(‘p’) don’t include ‘p’ elements in setdon’t include ‘p’ elements in set
• .add(‘p’).add(‘p’) add <p> elements to setadd <p> elements to set
• .remove().remove() removes all the elements from the page DOMremoves all the elements from the page DOM
• .empty().empty() removes the contents of all the elementsremoves the contents of all the elements
• .filter(fn/sel).filter(fn/sel) selects elements where the func returns true or selselects elements where the func returns true or sel
• .find(selector).find(selector) selects elements meeting the selector criteriaselects elements meeting the selector criteria
• .parent().parent() returns the parent of each element in setreturns the parent of each element in set
• .children().children() returns all the children of each element in setreturns all the children of each element in set
• .next().next() gets next element of each element in setgets next element of each element in set
• .prev().prev() gets previous element of each element in setgets previous element of each element in set
• .siblings().siblings() gets all the siblings of the current elementgets all the siblings of the current element
Tutorial 3 – Formatting ElementsTutorial 3 – Formatting Elements
• .css(property, value).css(property, value)
• .html().html()
• .val().val() (form elements)(form elements)
• .text().text()
• .addClass(‘class’).addClass(‘class’)
• .removeClass(‘class’).removeClass(‘class’)
Tutorial 4 – Add Page ElementsTutorial 4 – Add Page Elements
• $(‘#target’).before(‘<p>Inserted before #target</p>’);$(‘#target’).before(‘<p>Inserted before #target</p>’);
• $(‘#target’).after(‘<p>This is added after #target</p>’);$(‘#target’).after(‘<p>This is added after #target</p>’);
• $(‘#target’).append(‘<p>Goes inside #target, at end</p>’);$(‘#target’).append(‘<p>Goes inside #target, at end</p>’);
• $(‘#target’).wrap(‘<div></div>’);$(‘#target’).wrap(‘<div></div>’);
Adding EventsAdding Events
• Mouseover events – bind, hover, toggleMouseover events – bind, hover, toggle
• Button click eventsButton click events
• KeystrokesKeystrokes
Event BackgroundEvent Background
• DOM Level 2 Event ModelDOM Level 2 Event Model
– Multiple event handlers, or listeners, can beMultiple event handlers, or listeners, can be
established on an elementestablished on an element
– These handlers cannot be relied upon to runThese handlers cannot be relied upon to run
an any particular orderan any particular order
– When triggered, the event propagates fromWhen triggered, the event propagates from
the top down (capture phase) or bottom upthe top down (capture phase) or bottom up
(bubble phase)(bubble phase)
– IE doesn’t support the “capture phase”IE doesn’t support the “capture phase”
Basic Syntax of Event BindingBasic Syntax of Event Binding
• $(‘img’).bind(‘click’,function(event){alert(‘Howdy’;});$(‘img’).bind(‘click’,function(event){alert(‘Howdy’;});
• $(‘img’).bind(‘click’,imgclick(event));$(‘img’).bind(‘click’,imgclick(event));
– Allows unbinding the functionAllows unbinding the function
• $(‘img’).unbind(‘click’,imgclick());$(‘img’).unbind(‘click’,imgclick());
• $(‘img’).unbind(‘click’);$(‘img’).unbind(‘click’);
• $(‘img’).one(‘click’,imgclick(event));$(‘img’).one(‘click’,imgclick(event));
– Only works onceOnly works once
• $(‘img’).click(imgclick);$(‘img’).click(imgclick);
• $(‘img’).toggle(click1, click2);$(‘img’).toggle(click1, click2);
• $(‘img’).hover(mouseover, mouseout);$(‘img’).hover(mouseover, mouseout);
Element Properties – “this”Element Properties – “this”
• thisthis
• this.idthis.id
• this.tagNamethis.tagName
• this.attrthis.attr
• this.srcthis.src
• this.classnamethis.classname
• this.titlethis.title
• this.altthis.alt
• this.valuethis.value (for form elements)(for form elements)
‘‘Event’ propertiesEvent’ properties
• event.targetevent.target ref to element triggering eventref to element triggering event
• Event.target.idEvent.target.id id of element triggering eventid of element triggering event
• event.currentTargetevent.currentTarget
• event.typeevent.type type of event triggeredtype of event triggered
• event.dataevent.data second parm in the bind() funcsecond parm in the bind() func
• Various mouse coordinate propertiesVarious mouse coordinate properties
• Various keystroke related propertiesVarious keystroke related properties
Event MethodsEvent Methods
• .stopPropagation().stopPropagation() no bubblingno bubbling
• .preventDefault().preventDefault() no <a> link, no <form> submitno <a> link, no <form> submit
• .trigger(eventType).trigger(eventType) does not actually trigger thedoes not actually trigger the
event, but calls the appropriate function specified as theevent, but calls the appropriate function specified as the
one tied to the eventTypeone tied to the eventType
• .click(), blur(), focus(), select(), submit().click(), blur(), focus(), select(), submit()
– With no parameter, invokes the event handlers, likeWith no parameter, invokes the event handlers, like
trigger does, for all the elements in the wrapped settrigger does, for all the elements in the wrapped set
Shortcut Event BindingShortcut Event Binding
• .click(func).click(func)
• .submit(func).submit(func)
• .dblclick(func).dblclick(func)
• .mouseover(func).mouseover(func)
• .mouseout(func).mouseout(func)
• .select(func).select(func)
Useful Event FunctionsUseful Event Functions
• .hide().hide() display:truedisplay:true
• .show().show() display:nonedisplay:none
• .toggle(func1, func2) first click calls func1, next.toggle(func1, func2) first click calls func1, next
click executes func2click executes func2
• .hover(over, out).hover(over, out) mouseover, mouseoutmouseover, mouseout
AJAXAJAX
• What is AJAXWhat is AJAX
• The basic AJAX function –The basic AJAX function –
XMLHttpRequestXMLHttpRequest
• Initiating a requestInitiating a request
• Getting the responseGetting the response

More Related Content

What's hot

ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
DivyanshGupta922023
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
Jeff Fox
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
Partnered Health
 
Javascript
JavascriptJavascript
Javascript
Manav Prasad
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
Shlomi Komemi
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
Mukesh Kumar
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Angular Introduction By Surekha Gadkari
Angular Introduction By Surekha GadkariAngular Introduction By Surekha Gadkari
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
Reactjs
ReactjsReactjs
Reactjs
Reactjs Reactjs
Reactjs
Neha Sharma
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
Amit Baghel
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Priya Goyal
 
Learn react-js
Learn react-jsLearn react-js
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
Rob Eisenberg
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScript
Rajat Saxena
 

What's hot (20)

ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Javascript
JavascriptJavascript
Javascript
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Javascript
JavascriptJavascript
Javascript
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Angular Introduction By Surekha Gadkari
Angular Introduction By Surekha GadkariAngular Introduction By Surekha Gadkari
Angular Introduction By Surekha Gadkari
 
Reactjs
ReactjsReactjs
Reactjs
 
Reactjs
Reactjs Reactjs
Reactjs
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScript
 

Viewers also liked

jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
Arwid Bancewicz
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
manugoel2003
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
NexThoughts Technologies
 
Grails Services
Grails ServicesGrails Services
Grails Services
NexThoughts Technologies
 
Grails Plugins
Grails PluginsGrails Plugins
Grails Plugins
NexThoughts Technologies
 
Bootstrap
BootstrapBootstrap
GORM
GORMGORM
Unit testing
Unit testingUnit testing
Linux Introduction
Linux IntroductionLinux Introduction
Linux Introduction
NexThoughts Technologies
 
Grails Views
Grails ViewsGrails Views
Introduction to Grails
Introduction to GrailsIntroduction to Grails
Introduction to Grails
NexThoughts Technologies
 
Groovy intro
Groovy introGroovy intro
Groovy
GroovyGroovy
Meta Programming in Groovy
Meta Programming in GroovyMeta Programming in Groovy
Meta Programming in Groovy
NexThoughts Technologies
 
Docker
DockerDocker
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
NexThoughts Technologies
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
NexThoughts Technologies
 
Mixpanel
MixpanelMixpanel
MetaProgramming with Groovy
MetaProgramming with GroovyMetaProgramming with Groovy
MetaProgramming with Groovy
NexThoughts Technologies
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
NexThoughts Technologies
 

Viewers also liked (20)

jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 
Grails Services
Grails ServicesGrails Services
Grails Services
 
Grails Plugins
Grails PluginsGrails Plugins
Grails Plugins
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
GORM
GORMGORM
GORM
 
Unit testing
Unit testingUnit testing
Unit testing
 
Linux Introduction
Linux IntroductionLinux Introduction
Linux Introduction
 
Grails Views
Grails ViewsGrails Views
Grails Views
 
Introduction to Grails
Introduction to GrailsIntroduction to Grails
Introduction to Grails
 
Groovy intro
Groovy introGroovy intro
Groovy intro
 
Groovy
GroovyGroovy
Groovy
 
Meta Programming in Groovy
Meta Programming in GroovyMeta Programming in Groovy
Meta Programming in Groovy
 
Docker
DockerDocker
Docker
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Mixpanel
MixpanelMixpanel
Mixpanel
 
MetaProgramming with Groovy
MetaProgramming with GroovyMetaProgramming with Groovy
MetaProgramming with Groovy
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 

Similar to JQuery introduction

J query introduction
J query introductionJ query introduction
J query introduction
SMS_VietNam
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Sean Burgess
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
Gary Yeh
 
J query presentation
J query presentationJ query presentation
J query presentation
akanksha17
 
J query presentation
J query presentationJ query presentation
J query presentation
sawarkar17
 
J Query
J QueryJ Query
J Query
ravinxg
 
Jquery
JqueryJquery
Jquery
Zoya Shaikh
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Laila Buncab
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
iFour Institute - Sustainable Learning
 
J query module1
J query module1J query module1
J query module1
Srivatsan Krishnamachari
 
JQuery
JQueryJQuery
JQuery
Jacob Nelson
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
Gill Cleeren
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
Simon Willison
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
Russ Fustino
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentials
Mark Rackley
 
jQuery Learning
jQuery LearningjQuery Learning
jQuery Learning
Uzair Ali
 
JQuery
JQueryJQuery
JQuery
JQueryJQuery

Similar to JQuery introduction (20)

J query introduction
J query introductionJ query introduction
J query introduction
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
J query presentation
J query presentationJ query presentation
J query presentation
 
J query presentation
J query presentationJ query presentation
J query presentation
 
J Query
J QueryJ Query
J Query
 
Jquery
JqueryJquery
Jquery
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
J query module1
J query module1J query module1
J query module1
 
JQuery
JQueryJQuery
JQuery
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 
JavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) uploadJavaScript for ASP.NET programmers (webcast) upload
JavaScript for ASP.NET programmers (webcast) upload
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentials
 
jQuery Learning
jQuery LearningjQuery Learning
jQuery Learning
 
JQuery
JQueryJQuery
JQuery
 
JQuery
JQueryJQuery
JQuery
 

More from NexThoughts Technologies

Alexa skill
Alexa skillAlexa skill
GraalVM
GraalVMGraalVM
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
NexThoughts Technologies
 
Apache commons
Apache commonsApache commons
Apache commons
NexThoughts Technologies
 
HazelCast
HazelCastHazelCast
MySQL Pro
MySQL ProMySQL Pro
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
NexThoughts Technologies
 
Swagger
SwaggerSwagger
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
NexThoughts Technologies
 
Arango DB
Arango DBArango DB
Jython
JythonJython
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
NexThoughts Technologies
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
NexThoughts Technologies
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
NexThoughts Technologies
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
NexThoughts Technologies
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
NexThoughts Technologies
 
Ethereum
EthereumEthereum
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
NexThoughts Technologies
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
NexThoughts Technologies
 
Google authentication
Google authenticationGoogle authentication
Google authentication
NexThoughts Technologies
 

More from NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 

Recently uploaded

Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
Emerging Tech
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
Tatiana Al-Chueyr
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 

Recently uploaded (20)

Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
Best Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdfBest Practices for Effectively Running dbt in Airflow.pdf
Best Practices for Effectively Running dbt in Airflow.pdf
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 

JQuery introduction

  • 1. jQueryjQuery The Way to JavaScript and RichThe Way to JavaScript and Rich Internet ApplicationsInternet Applications
  • 2. Introduction to jQueryIntroduction to jQuery • Developed by John Resig at Rochester Institute of TechnologyDeveloped by John Resig at Rochester Institute of Technology • ““jQueryjQuery is a lightweightis a lightweight JavaScript libraryJavaScript library that emphasizesthat emphasizes interaction betweeninteraction between JavaScriptJavaScript andand HTMLHTML. It was released in. It was released in January 2006 atJanuary 2006 at BarCampBarCamp NYC byNYC by John ResigJohn Resig.”.” • ““jQuery isjQuery is free, open source softwarefree, open source software Dual-licensedDual-licensed under theunder the MIT LicenseMIT License and theand the GNU General Public LicenseGNU General Public License.”.” • ““It’s all about simplicity. Why should web developers be forced toIt’s all about simplicity. Why should web developers be forced to write long, complex, book-length pieces of code when they want towrite long, complex, book-length pieces of code when they want to create simple pieces of interaction?”create simple pieces of interaction?” • Current version is 1.3.2.Current version is 1.3.2. • Version 1.4 due out soon.Version 1.4 due out soon.
  • 3. John ResigJohn Resig • John Resig is a JavaScript Tool DeveloperJohn Resig is a JavaScript Tool Developer for thefor the Mozilla CorporationMozilla Corporation and the authorand the author of the bookof the book Pro JavaScript TechniquesPro JavaScript Techniques.. He's also the creator and lead developer ofHe's also the creator and lead developer of thethe jQuery JavaScript libraryjQuery JavaScript library.. • Currently, John is located in Boston, MA.Currently, John is located in Boston, MA. He's hard at work on his second book,He's hard at work on his second book, Secrets of the JavaScript NinjaSecrets of the JavaScript Ninja, due in, due in bookstores in 2009.bookstores in 2009. • MicrosoftMicrosoft andand NokiaNokia have announcedhave announced plans to bundle jQuery on their platforms,plans to bundle jQuery on their platforms, [1][1] Microsoft adopting it initially withinMicrosoft adopting it initially within Visual StudioVisual Studio[2][2] for use within Microsoft'sfor use within Microsoft's ASP.NET AJAXASP.NET AJAX framework andframework and ASP.NET MVC FrameworkASP.NET MVC Framework whilst Nokiawhilst Nokia will integrate it into their Web Run-Timewill integrate it into their Web Run-Time platform.platform.
  • 4. Introduction to jQueryIntroduction to jQuery • Why do I want itWhy do I want it – Rich Internet Applications (RIA)Rich Internet Applications (RIA) – Dynamic HTML (DHTML)Dynamic HTML (DHTML) • How do I get itHow do I get it – www.jquery.comwww.jquery.com • How can I learn itHow can I learn it – jQuery in ActionjQuery in Action by Bibeault & Katz, Manningby Bibeault & Katz, Manning – jQuery Visual Quickstart GuidejQuery Visual Quickstart Guide by Holzner, Peachpitby Holzner, Peachpit – www.jquery.comwww.jquery.com – docs.jquery.comdocs.jquery.com – www.visualjquery.comwww.visualjquery.com – www.Jqueryfordesigners.comwww.Jqueryfordesigners.com – www.gscottolson.com/weblog/ - cheat sheetwww.gscottolson.com/weblog/ - cheat sheet – www.javascripttoolbox.com/jquerywww.javascripttoolbox.com/jquery
  • 5. Plan for the 4 sessionsPlan for the 4 sessions • Class I – Introduction, installation, “HowdyClass I – Introduction, installation, “Howdy World”, Ready function, DOM, SelectingWorld”, Ready function, DOM, Selecting and Formatting web page elementsand Formatting web page elements • Class II – Events and AnimationsClass II – Events and Animations • Class III – jQuery Plugin librariesClass III – jQuery Plugin libraries • Class IV – AJAX with PHP and ASP.NETClass IV – AJAX with PHP and ASP.NET
  • 6. Introduction to jQueryIntroduction to jQuery • Installation – You just download theInstallation – You just download the jquery-1.3.2.js file and put it in yourjquery-1.3.2.js file and put it in your website folderwebsite folder – Can access via URLCan access via URL
  • 7. What jQuery DoesWhat jQuery Does • ““Unobtrusive” JavaScript – separation ofUnobtrusive” JavaScript – separation of behaviorbehavior from structurefrom structure • CSS – separation ofCSS – separation of stylestyle from structurefrom structure • Allows adding JavaScript to your web pagesAllows adding JavaScript to your web pages • Advantages overAdvantages over justjust JavaScriptJavaScript – Much easier to useMuch easier to use – Eliminates cross-browser problemsEliminates cross-browser problems • HTML to CSS to DHTMLHTML to CSS to DHTML
  • 8. 5 Things jQuery Provides5 Things jQuery Provides • Select DOM (Document Object Model) elementsSelect DOM (Document Object Model) elements on a page – one element or a group of themon a page – one element or a group of them • Set properties of DOM elements, in groupsSet properties of DOM elements, in groups (“Find something, do something with it”)(“Find something, do something with it”) • Creates, deletes, shows, hides DOM elementsCreates, deletes, shows, hides DOM elements • Defines event behavior on a page (click, mouseDefines event behavior on a page (click, mouse movement, dynamic styles, animations, dynamicmovement, dynamic styles, animations, dynamic content)content) • AJAX callsAJAX calls
  • 9. The DOMThe DOM • Document Object ModelDocument Object Model • jQuery is “DOM scripting”jQuery is “DOM scripting” • Heirarchal structure of a web pageHeirarchal structure of a web page • You can add and subtract DOM elementsYou can add and subtract DOM elements on the flyon the fly • You can change the properties andYou can change the properties and contents of DOM elements on the flycontents of DOM elements on the fly
  • 10. The DOMThe DOM • ““TheThe Document Object ModelDocument Object Model ((DOMDOM) is a cross-platform and) is a cross-platform and language-independent convention for representing and interactinglanguage-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of thewith objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulatedDOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use.” Wikipediawithin the syntax of the programming language in use.” Wikipedia
  • 11. The jQuery FunctionThe jQuery Function • jQuery() = $()jQuery() = $() • $(function)$(function) The “Ready” handlerThe “Ready” handler • $(‘selector’)$(‘selector’) Element selector expressionElement selector expression • $(element)$(element) Specify element(s) directlySpecify element(s) directly • $(‘HTML’)$(‘HTML’) HTML creationHTML creation • $.function()$.function() Execute a jQuery functionExecute a jQuery function • $.fn.myfunc(){}$.fn.myfunc(){} Create jQuery functionCreate jQuery function
  • 12. Tutorial 1 – The Ready FunctionTutorial 1 – The Ready Function • Set up a basic HTML page and add jQuerySet up a basic HTML page and add jQuery • Create a “ready” functionCreate a “ready” function • Call a functionCall a function • 5 ways to specify the ready function5 ways to specify the ready function – jquery(document).ready(function(){…};);jquery(document).ready(function(){…};); – jquery().ready(function(){…};)jquery().ready(function(){…};) – jquery(function(){…};)jquery(function(){…};) – jquery(dofunc);jquery(dofunc); – $(dofunc);$(dofunc);
  • 13. Tutorial 2 – Selecting ElementsTutorial 2 – Selecting Elements Creating a “wrapped set”Creating a “wrapped set” • $(selector)$(selector) • selector:selector: – $(‘#id’)$(‘#id’) id of elementid of element – $(‘p’)$(‘p’) tag nametag name – $(‘.class’)$(‘.class’) CSS classCSS class – $(‘p.class’)$(‘p.class’) <p> elements having the CSS class<p> elements having the CSS class – $(‘p:first’)$(‘p:first’) $(‘p:last’)$(‘p:last’) $(‘p:odd’)$(‘p:odd’) $(‘p:even’)$(‘p:even’) – $(‘p:eq(2)’)$(‘p:eq(2)’) gets the 2gets the 2ndnd <p> element (1 based)<p> element (1 based) – $(‘p’)[1]$(‘p’)[1] gets the 2gets the 2ndnd <p> element (0 based)<p> element (0 based) – $(‘p:nth-child(3))$(‘p:nth-child(3)) gets the 3gets the 3rdrd <p> element of the parent. n=even, odd too.<p> element of the parent. n=even, odd too. – $(‘p:nth-child(5n+1)’)$(‘p:nth-child(5n+1)’) gets the 1gets the 1stst element after every 5th oneelement after every 5th one – $(‘p a’)$(‘p a’) <a> elements, descended from a <p><a> elements, descended from a <p> – $(‘p>a’)$(‘p>a’) <a> elements, direct child of a <p><a> elements, direct child of a <p> – $(‘p+a’)$(‘p+a’) <a> elements, directly following a <p><a> elements, directly following a <p> – $(‘p, a’)$(‘p, a’) <p> and <a> elements<p> and <a> elements – $(‘li:has(ul)’)$(‘li:has(ul)’) <li> elements that have at least one <ul> descendent<li> elements that have at least one <ul> descendent – $(‘:not(p)’)$(‘:not(p)’) all elements but <p> elementsall elements but <p> elements – $(‘p:hidden’)$(‘p:hidden’) only <p> elements that are hiddenonly <p> elements that are hidden – $(‘p:empty’)$(‘p:empty’) <p> elements that have no child elements<p> elements that have no child elements
  • 14. Selecting Elements, cont.Selecting Elements, cont. • $(‘img’[alt])$(‘img’[alt]) <img> elements having an alt attribute<img> elements having an alt attribute • $(‘a’[href^=http://])$(‘a’[href^=http://]) <a> elements with an href attribute<a> elements with an href attribute starting with ‘http://’starting with ‘http://’ • $(‘a’[href$=.pdf])$(‘a’[href$=.pdf]) <a> elements with an href attribute<a> elements with an href attribute ending with ‘.pdf’ending with ‘.pdf’ • $(‘a’[href*=ntpcug])$(‘a’[href*=ntpcug]) <a> elements with an href attriute<a> elements with an href attriute containing ‘ntpcug’containing ‘ntpcug’
  • 15. Useful jQuery FunctionsUseful jQuery Functions • .each().each() iterate over the setiterate over the set • .size().size() number of elements in setnumber of elements in set • .end().end() reverts to the previous setreverts to the previous set • .get(n).get(n) get just the nth element (0 based)get just the nth element (0 based) • .eq(n).eq(n) get just the nth element (0 based) also .lt(n) & .gt(n)get just the nth element (0 based) also .lt(n) & .gt(n) • .slice(n,m).slice(n,m) gets only nth to (m-1)th elementsgets only nth to (m-1)th elements • .not(‘p’).not(‘p’) don’t include ‘p’ elements in setdon’t include ‘p’ elements in set • .add(‘p’).add(‘p’) add <p> elements to setadd <p> elements to set • .remove().remove() removes all the elements from the page DOMremoves all the elements from the page DOM • .empty().empty() removes the contents of all the elementsremoves the contents of all the elements • .filter(fn/sel).filter(fn/sel) selects elements where the func returns true or selselects elements where the func returns true or sel • .find(selector).find(selector) selects elements meeting the selector criteriaselects elements meeting the selector criteria • .parent().parent() returns the parent of each element in setreturns the parent of each element in set • .children().children() returns all the children of each element in setreturns all the children of each element in set • .next().next() gets next element of each element in setgets next element of each element in set • .prev().prev() gets previous element of each element in setgets previous element of each element in set • .siblings().siblings() gets all the siblings of the current elementgets all the siblings of the current element
  • 16. Tutorial 3 – Formatting ElementsTutorial 3 – Formatting Elements • .css(property, value).css(property, value) • .html().html() • .val().val() (form elements)(form elements) • .text().text() • .addClass(‘class’).addClass(‘class’) • .removeClass(‘class’).removeClass(‘class’)
  • 17. Tutorial 4 – Add Page ElementsTutorial 4 – Add Page Elements • $(‘#target’).before(‘<p>Inserted before #target</p>’);$(‘#target’).before(‘<p>Inserted before #target</p>’); • $(‘#target’).after(‘<p>This is added after #target</p>’);$(‘#target’).after(‘<p>This is added after #target</p>’); • $(‘#target’).append(‘<p>Goes inside #target, at end</p>’);$(‘#target’).append(‘<p>Goes inside #target, at end</p>’); • $(‘#target’).wrap(‘<div></div>’);$(‘#target’).wrap(‘<div></div>’);
  • 18. Adding EventsAdding Events • Mouseover events – bind, hover, toggleMouseover events – bind, hover, toggle • Button click eventsButton click events • KeystrokesKeystrokes
  • 19. Event BackgroundEvent Background • DOM Level 2 Event ModelDOM Level 2 Event Model – Multiple event handlers, or listeners, can beMultiple event handlers, or listeners, can be established on an elementestablished on an element – These handlers cannot be relied upon to runThese handlers cannot be relied upon to run an any particular orderan any particular order – When triggered, the event propagates fromWhen triggered, the event propagates from the top down (capture phase) or bottom upthe top down (capture phase) or bottom up (bubble phase)(bubble phase) – IE doesn’t support the “capture phase”IE doesn’t support the “capture phase”
  • 20. Basic Syntax of Event BindingBasic Syntax of Event Binding • $(‘img’).bind(‘click’,function(event){alert(‘Howdy’;});$(‘img’).bind(‘click’,function(event){alert(‘Howdy’;}); • $(‘img’).bind(‘click’,imgclick(event));$(‘img’).bind(‘click’,imgclick(event)); – Allows unbinding the functionAllows unbinding the function • $(‘img’).unbind(‘click’,imgclick());$(‘img’).unbind(‘click’,imgclick()); • $(‘img’).unbind(‘click’);$(‘img’).unbind(‘click’); • $(‘img’).one(‘click’,imgclick(event));$(‘img’).one(‘click’,imgclick(event)); – Only works onceOnly works once • $(‘img’).click(imgclick);$(‘img’).click(imgclick); • $(‘img’).toggle(click1, click2);$(‘img’).toggle(click1, click2); • $(‘img’).hover(mouseover, mouseout);$(‘img’).hover(mouseover, mouseout);
  • 21. Element Properties – “this”Element Properties – “this” • thisthis • this.idthis.id • this.tagNamethis.tagName • this.attrthis.attr • this.srcthis.src • this.classnamethis.classname • this.titlethis.title • this.altthis.alt • this.valuethis.value (for form elements)(for form elements)
  • 22. ‘‘Event’ propertiesEvent’ properties • event.targetevent.target ref to element triggering eventref to element triggering event • Event.target.idEvent.target.id id of element triggering eventid of element triggering event • event.currentTargetevent.currentTarget • event.typeevent.type type of event triggeredtype of event triggered • event.dataevent.data second parm in the bind() funcsecond parm in the bind() func • Various mouse coordinate propertiesVarious mouse coordinate properties • Various keystroke related propertiesVarious keystroke related properties
  • 23. Event MethodsEvent Methods • .stopPropagation().stopPropagation() no bubblingno bubbling • .preventDefault().preventDefault() no <a> link, no <form> submitno <a> link, no <form> submit • .trigger(eventType).trigger(eventType) does not actually trigger thedoes not actually trigger the event, but calls the appropriate function specified as theevent, but calls the appropriate function specified as the one tied to the eventTypeone tied to the eventType • .click(), blur(), focus(), select(), submit().click(), blur(), focus(), select(), submit() – With no parameter, invokes the event handlers, likeWith no parameter, invokes the event handlers, like trigger does, for all the elements in the wrapped settrigger does, for all the elements in the wrapped set
  • 24. Shortcut Event BindingShortcut Event Binding • .click(func).click(func) • .submit(func).submit(func) • .dblclick(func).dblclick(func) • .mouseover(func).mouseover(func) • .mouseout(func).mouseout(func) • .select(func).select(func)
  • 25. Useful Event FunctionsUseful Event Functions • .hide().hide() display:truedisplay:true • .show().show() display:nonedisplay:none • .toggle(func1, func2) first click calls func1, next.toggle(func1, func2) first click calls func1, next click executes func2click executes func2 • .hover(over, out).hover(over, out) mouseover, mouseoutmouseover, mouseout
  • 26. AJAXAJAX • What is AJAXWhat is AJAX • The basic AJAX function –The basic AJAX function – XMLHttpRequestXMLHttpRequest • Initiating a requestInitiating a request • Getting the responseGetting the response