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

 $( [find 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 first 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
 $( [find 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 specific 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/file/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

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
 
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

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
 
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
 

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
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryAkshay Mathur
 
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 (1).ppt
6867389 (1).ppt6867389 (1).ppt
6867389 (1).ppt
 
6867389.ppt
6867389.ppt6867389.ppt
6867389.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