SlideShare a Scribd company logo
1 of 52
Download to read offline
Javascript, jQuery
     and jQuery UI

presentation by: Tom Friedhof
Stuff Iā€™ll cover today.
ā€¢ JavaScript.
ā€¢ The DOM (Document Object Model).
ā€¢ Adding Behaviors to HTML.
ā€¢ You donā€™t need to learn the DOM
ā€¢ jQuery
ā€¢ jQuery UI Tabs
ā€¢ jQuery the Drupal Way
What is JavaScript?
What is JavaScript?

ā€¢ Client Side Scripting Language
ā€¢ JavaScript is not Java
ā€¢ Used to provide instant feedback
 ā€¢ Better Usability
 ā€¢ Richer Web Applications
ā€¢ Works the DOM (i.e. HTML, XML, etc...)
What is the DOM?
The Document Object Model (DOM) is an
API for HTML and XML documents. It
provides a structural representation of
the document, enabling you to modify its
content and visual presentation. Essentially,
it connects web pages to scripts or
programming languages.


     https://developer.mozilla.org/en/DOM
HTML and the DOM.
                                       html

                          head
                                              body

                 meta         title
                                              div



                         ul            div           div   div



            li      li            li   p             p     p



            a       a             a
The real DOM
                                                    Document           .getElementById(ā€˜tabsā€™)
                                                       html
                         Element
                               head

                                                                                 id=ā€tabsā€
                                                              Element
                                                                body

          Element                Element
            meta                      title

                                                              Element       .innerHTML
                                                                div




                    Element                         Element             Element        Element
                          ul                          div                  div               div




Element        Element                    Element   Element             Element        Element
   li               li                        li       p                   p                 p




Element        Element                    Element
   a                a                         a
One other thing to mention
The DOM is NOT JavaScript
 Blue is for JavaScript, Red is for DOM


 var anchorTags =
   document.getElementsByTagName(ā€œaā€)
 for (var i = 0;i <anchorTags.length; i++)
 {
 alert(ā€œHref of this a element is: ā€œ +
   anchorTags[i].href);
 }

https://developer.mozilla.org/en/The_DOM_and_JavaScript
Adding Behaviors to HTML


    EVENTS
onLoad
onClick
onMouseOver
etc...

http://www.w3schools.com/jsref/jsref_events.asp
Thatā€™s the Basics.
Awesome!

We know the DOM

   Now What?
You donā€™t need to
  learn the DOM
 JavaScript Libraries can
work with the DOM better
        than you!.
JavaScript Libraries
encapsulate browser
   inconsistencies.
jQuery
Write Less. Do More
jQuery Basics

 $( [ļ¬nd something] ).doSomething();


           CSS Selector        jQuery Method
Hide Children of Element
Get Elements by Class




Good Luck doing this with just the DOM and JavaScript
jQuery.com
visualjquery.com
OK... Letā€™s build tabs
An Example

http://www.elated.com/articles/javascript-tabs/
Objective.

ā€¢ Turn an HTML Document with an
  Unordered List into tabbed content.
  ā€¢ Format the HTML using CSS.
  ā€¢ Add Behavior so that you can change
    tabs onClick of the tab name.
The HTML (again)
The CSS




  A topic for another day
Four JavaScript Functions

ā€¢ init()       .
             sets up the tabs


ā€¢ showTab()              displays a clicked tab's content and highlights the tab.


ā€¢ getFirstChildWithTagName()                                   is a helper
  function that retrieves the ļ¬rst child of a given element that has a given tag
  name.


ā€¢ getHash()            is another short helper function that takes a URL and
  returns the part of the URL that appears after the hash (#) symbol.
Demo
 index_hard.html
You need to know a lot.

ā€¢ CSS
ā€¢ Document Object Model (DOM)
ā€¢ JavaScript
ā€¢ Language Constructs
ā€¢ Verify that the JavaScript works in other
  browsers.
This wonā€™t work in IE




       Finds a different node in IE
I just want tabs.

Not a Computer
Science Degree
The Easy Way.
jQuery
   and
jQuery UI
Review jQuery Basics
 $( [ļ¬nd something] ).doSomething();




 $(ā€œ#tabsā€).tabs();
           CSS Selector   jQuery UI Method
A Few jQuery UI Methods
 .draggable()
 .droppable()
 .selectable()
 .accordion()
 .slider()
 etc...
Include the Library

and a one liner to implement
The DOM has to be ready


 $(document).ready(function() {
  // Code Goes Here
 });
The DOM has to be ready


 $(document).ready(function() {
       $(ā€œ#tabsā€).tabs();
 });
The Drupal Way


 Drupal.behaviors.loadTabs = function(context) {
      // Code Goes Here
 };
The Drupal Way


 Drupal.behaviors.loadTabs = function(context) {
      $(ā€œ#tabsā€).tabs();
 };
Why use Drupal.behaviors?

ā€¢ Ability to override JS
ā€¢ Behaviors are re-attachable
ā€¢ Attach Behaviors to a speciļ¬c context
   ā€¢ HTML loaded via AHAH

Drupal.attachBehaviors(elem);
Demo
 index_easy.html
Demo
 Drupal.behaviors
Resources

 http://jquery.com and http://jqueryui.com

 http://www.elated.com/articles/javascript-tabs/

 http://api.drupal.org/api/ļ¬le/developer/topics/javascript_startup_guide.html/6

 http://raincitystudios.com/blogs-and-pods/katherine-bailey/the-lowdown-
 jquery-drupal-part-two

 http://www.chapterthree.com/blog/josh_koenig/
 handling_aysnchronous_data_drupal_session_materials

 https://developer.mozilla.org/en/JavaScript
Questions?

More Related Content

What's hot

Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQueryWildan Maulana
Ā 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
Ā 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQueryRemy Sharp
Ā 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuerySteve Krueger
Ā 
Java Script and HTML.
Java Script and HTML.Java Script and HTML.
Java Script and HTML.Akshat Vig
Ā 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginnerkumar gaurav
Ā 
Ch5(ms access with php)
Ch5(ms access with php)Ch5(ms access with php)
Ch5(ms access with php)Chhom Karath
Ā 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothBhavsingh Maloth
Ā 
Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)Julie Meloni
Ā 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Ayes Chinmay
Ā 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQueryAlan Hecht
Ā 
State of jQuery and Drupal
State of jQuery and DrupalState of jQuery and Drupal
State of jQuery and Drupaljeresig
Ā 

What's hot (20)

Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
Ā 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Ā 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
Ā 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
Ā 
Designers Guide To jQuery
Designers Guide To jQueryDesigners Guide To jQuery
Designers Guide To jQuery
Ā 
Java Script and HTML.
Java Script and HTML.Java Script and HTML.
Java Script and HTML.
Ā 
Learn css3
Learn css3Learn css3
Learn css3
Ā 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
Ā 
Ch5(ms access with php)
Ch5(ms access with php)Ch5(ms access with php)
Ch5(ms access with php)
Ā 
Jquery
JqueryJquery
Jquery
Ā 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
Ā 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
Ā 
Java script
Java scriptJava script
Java script
Ā 
Week3
Week3Week3
Week3
Ā 
Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)Introduction to Programming (well, kind of.)
Introduction to Programming (well, kind of.)
Ā 
Jquery library
Jquery libraryJquery library
Jquery library
Ā 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Ā 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
Ā 
JQuery
JQueryJQuery
JQuery
Ā 
State of jQuery and Drupal
State of jQuery and DrupalState of jQuery and Drupal
State of jQuery and Drupal
Ā 

Viewers also liked

jQuery UI and Plugins
jQuery UI and PluginsjQuery UI and Plugins
jQuery UI and PluginsMarc Grabanski
Ā 
State of jQuery '09
State of jQuery '09State of jQuery '09
State of jQuery '09jeresig
Ā 
TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios
 TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios
TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfoliosfinance9
Ā 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQueryRemy Sharp
Ā 
Sencha Touch for the Mobile Web
Sencha Touch for the Mobile WebSencha Touch for the Mobile Web
Sencha Touch for the Mobile WebSencha
Ā 
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchJQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchSteve Drucker
Ā 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UIPaul Bakaus
Ā 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQueryAchmad Solichin
Ā 
Learning from the Best jQuery Plugins
Learning from the Best jQuery PluginsLearning from the Best jQuery Plugins
Learning from the Best jQuery PluginsMarc Grabanski
Ā 
CSS/SVG Matrix Transforms
CSS/SVG Matrix TransformsCSS/SVG Matrix Transforms
CSS/SVG Matrix TransformsMarc Grabanski
Ā 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery EssentialsMarc Grabanski
Ā 

Viewers also liked (12)

jQuery UI and Plugins
jQuery UI and PluginsjQuery UI and Plugins
jQuery UI and Plugins
Ā 
State of jQuery '09
State of jQuery '09State of jQuery '09
State of jQuery '09
Ā 
TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios
 TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios
TIAA Traditional Annuity: Adding Safety and Stability to Retirement Portfolios
Ā 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
Ā 
Sencha Touch for the Mobile Web
Sencha Touch for the Mobile WebSencha Touch for the Mobile Web
Sencha Touch for the Mobile Web
Ā 
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha TouchJQuery Mobile vs Appcelerator Titanium vs Sencha Touch
JQuery Mobile vs Appcelerator Titanium vs Sencha Touch
Ā 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UI
Ā 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQuery
Ā 
Learning from the Best jQuery Plugins
Learning from the Best jQuery PluginsLearning from the Best jQuery Plugins
Learning from the Best jQuery Plugins
Ā 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Ā 
CSS/SVG Matrix Transforms
CSS/SVG Matrix TransformsCSS/SVG Matrix Transforms
CSS/SVG Matrix Transforms
Ā 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
Ā 

Similar to Javascript jQuery jQuery Ui

JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulationborkweb
Ā 
Document object model
Document object modelDocument object model
Document object modelAmit kumar
Ā 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance TipsRavi Raj
Ā 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)GOPAL BASAK
Ā 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScriptLilia Sfaxi
Ā 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaztestingphase
Ā 
Introduction to DOM
Introduction to DOMIntroduction to DOM
Introduction to DOMDaniel Bragais
Ā 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryAkshay Mathur
Ā 
J Query
J QueryJ Query
J Queryravinxg
Ā 
Web technologies-course 09.pptx
Web technologies-course 09.pptxWeb technologies-course 09.pptx
Web technologies-course 09.pptxStefan Oprea
Ā 
Dom date and objects and event handling
Dom date and objects and event handlingDom date and objects and event handling
Dom date and objects and event handlingsmitha273566
Ā 
WEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxWEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxkarthiksmart21
Ā 

Similar to Javascript jQuery jQuery Ui (20)

JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulation
Ā 
Document object model
Document object modelDocument object model
Document object model
Ā 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
Ā 
6867389.ppt
6867389.ppt6867389.ppt
6867389.ppt
Ā 
6867389 (1).ppt
6867389 (1).ppt6867389 (1).ppt
6867389 (1).ppt
Ā 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
Ā 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
Ā 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
Ā 
jQuery
jQueryjQuery
jQuery
Ā 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Ā 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
Ā 
DOM and Events
DOM and EventsDOM and Events
DOM and Events
Ā 
Introduction to DOM
Introduction to DOMIntroduction to DOM
Introduction to DOM
Ā 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Ā 
J Query
J QueryJ Query
J Query
Ā 
DOM Quick Overview
DOM Quick OverviewDOM Quick Overview
DOM Quick Overview
Ā 
Web technologies-course 09.pptx
Web technologies-course 09.pptxWeb technologies-course 09.pptx
Web technologies-course 09.pptx
Ā 
Dom date and objects and event handling
Dom date and objects and event handlingDom date and objects and event handling
Dom date and objects and event handling
Ā 
J query1
J query1J query1
J query1
Ā 
WEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxWEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptx
Ā 

Javascript jQuery jQuery Ui