Getting Started.  jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions.

Slides:



Advertisements
Similar presentations
JQuery CS 380: Web Programming. What is jQuery? jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling,
Advertisements

Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
JQuery CS 268. What is jQuery? From their web site:
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
JavaScript, jQuery & AJAX. What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript,
What is jQuery?  JavaScript Library  Functionality  DOM scripting & event handling  Ajax  User interface effects  Form validation 2.
JQuery Javascript Framework Aryo Pinandito. A Little Bit About jQuery  jQuery is an Open-Source JavaScript framework that simplifies cross-browser client.
JQuery March 09 th,2009 Create by
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
Webmasters' Guild Friday, June 4, 2010
Interacting with a Web Page using JavaScript Mat Kelly GTAI Presentation January 10, 2014.
Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Animation & Effects Using JQuery. What is jQuery? jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use.
JQuery Youn-Hee Han
. Taught by: Muhammad Ali Baloch midahot. WHAT IS JQUERY JQuery is a fast, small, and feature-rich JavaScript library. Simplifies the interaction between.
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
Introduction to jQuery. jQuery Quick facts Is a cross-compatible JavaScript library Released in 2006 by John Resig Simplifies HTML document traversing,
Web Development 101 Presented by John Valance
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
IS2802 Introduction to Multimedia Applications for Business Lecture 07: Introduction to jQuery Rob Gleasure
Unit 13 –JQuery Basics Instructor: Brent Presley.
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
Introduction to JQuery COGS 187A – Fall JQuery jQuery is a JavaScript library, and allows us to manipulate HTML and CSS after the page has been.
JQUERY AND AJAX
DOM & Jquery Nov. 09, Jquery JavaScript Library DOM (Document Object Model) HTML/XML/etc. Ajax (Asynchronous JavaScript and XML)
JQuery Tutorial. What is jQuery jQuery is a JavaScript Library The purpose of jQuery is to make it much easier to use JavaScript on your website JavaScript.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
.. WHAT IS JQUERY JQuery is a fast, small, and feature-rich JavaScript library. Simplifies the interaction between HTML and JavaScript. The jQuery library.
JQuery is a fast, small, and feature-rich javascript library. It makes things like HTML document traversal and manipulation, event handling, animation,
JQuery.
JQuery Fundamentals Introduction Tutorial Videos
What is jQuery?.
Vinay Vasyani Internet Programming
Programming Web Pages with JavaScript
Unit M Programming Web Pages with
12/04/12 JQuery I took these slides from the site because they were pretty good looking. Instructions for editing school and department titles: Select.
Unit M Programming Web Pages with
CGS 3066: Web Programming and Design Spring 2017
Introduction to Web programming
HTML.
JavaScript Introduction
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
..
Javascript and JQuery SRM DSC.
E-commerce Applications Development
Web Client Side Technologies Raneem Qaddoura
Presentation transcript:

Getting Started

 jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.  jQuery is designed to change the way that you write JavaScript. 2

 Cross browser : Latest version supports:  IE / FireFox / Safari / Opera /Chrome?  CSS-like syntax – easy for developers/non- developers to understand  Lightweight (compressed version)  Active developer community  Extensible - plugins 3

 A substitute for knowing JavaScript  jQuery is very useful, but you should still know how JavaScript works and how to use it correctly. This means more than Googling a jQuery/JavaScript tutorial and calling yourself an expert.  The answer to every problem  There is still plenty of functionality built into JavaScript that should be utilized! Don’t turn every project into a quest to ‘jQuery-ize’ the problem, use jQuery where it makes sense. Create solutions in environments where they belong.

jQuery Javascript

 Select DOM (Document Object Model) elements on a page – one element or a group of them  Set properties of DOM elements, in groups (“Find something, do something with it”)  Creates, deletes, shows, hides DOM elements  Defines event behavior on a page (click, mouse movement, dynamic styles, animations, dynamic content)  AJAX calls

 Strings and numbers - basic pieces of information  Variables - where to store pieces of information  Functions - how to call reusable pieces of code  Callbacks - functions that get called in response to something else  Arrays - store a list of values (like a list of variables)  Objects - understand a little bit about these  Conditionals - controlling what parts of a program executes

 Strings and numbers - basic pieces of information  Variables - where to store pieces of information  Functions - how to call reusable pieces of code  Callbacks - functions that get called in response to something else  Arrays - store a list of values (like a list of variables)  Objects - understand a little bit about these  Conditionals - controlling what parts of a program executes

 Similar to CSS - the less 'inline' the better. (Generalization)  Downright Bad: Include as an event  Even Less Good: Include in the tag  Less Good: Include in the tag  Best: Include external.js file

 jQuery is “DOM scripting”  The DOM is your html document code.  From the to the  The DOM is "ready" when everything on the page has loaded. Stylesheets JavaScripts Images

 “The Document Object Model (DOM) is a cross-platform and language- independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use.” Wikipediacross-platformlanguageobjects HTMLXHTMLXML You can add and subtract DOM elements on the fly You can change the properties and contents of DOM elements on the fly

In order to make sure that jQuery can find the element you asked it for, your browser needs to have loaded it (the DOM needs to be ready). Q. How can I be sure my code runs at DOM ready? A. Wrap all your jQuery code with the document ready function: $(document).ready(function(){ // insert jQuery code here… }); Or

Html: Hello World! I'm Eric Script: $(function(){ $("p").addClass("isCool"); //keep telling yourself that.. }); Resulting html: Hello World! I'm Eric

$(function(){ // = $(document).ready(function(){ }); $ Initiates the jQuery function $ = jQuery ("p") Grabs a DOM element using a CSS selector. Selector is in quotes. Creates a jQuery “Collection”.addClass("isCool"); Built in method that adds a class to the jQuery Collection Class is in quotes. ends with a semicolon.

 Uses the same syntax you use to style elements in CSS! $("p") $("div") $("#foo") id="foo" $(".foo") class= "foo" api.jquery.com/category/selectors/

 jQuery: $("p").addClass("sophisticated");  Before:  After: jsbin.com/ecayo3/18#slide22

 jQuery: $("p").removeClass("sophisticated") ;  Before:  After: jsbin.com/ecayo3/18#slide22

 jQuery: $("div").show();  Before:  After:

 jQuery: $("#eric").text("Is Cool");  Before: Is Lame  After: Is Cool jsbin.com/ecayo3/18#slide25

$("p").addClass("sophisticated").text("Hello World!").show();

$("#eric").click(function(){ $(this).text("Is Cool"); // this = #eric alert("Take that High School!"); }); $("#eric").click(function(event){ $(this).text("Is Cool“); // this = #eric alert("Take that High School!"); event.preventDefault(); //Prevents default action });

Show a hidden element.show() wrap an element with.wrap(" ") Select parent.parent("p") Get/Set innerHTML.html() Get/Set Value.val() api.jquery.com/

 Get   Installation – download the appropriate jquery.js file and put it in a folder  How to learn it   docs.jquery.com    - cheat sheet 

 $(selector).function(…) or $.function(…) or $(selector).function1(…).function2(…).functionN(…);  $() or jQuery()  JQuery objects are created by jQuery() or $()  jQuery object is a wrapper for a selected node or group of DOM nodes  $(“p”) is a JQuery object containing all the “p” elements in the document  selector  reference to an element or many different elements on in a document  Function - any jQuery supported method or plugin.  (…) refers to function parameters  Functions can be chained in sequence

 Think CSS!  jQuery has a built in DOM transversal engine.  $(selector) returns a list of elements on the page that match the “selector”.  Example: $(“input”) will return a list of ALL input elements on the page.

 Just add reference to Jquery JavaScript file from anywhere in your code.  Document.Ready is used to attach events and many other things using JQuery. $(document).ready(function() { alert(“Welcome to JQuery”); }); jQue ry 28

 Document -> Ready is equivalent to body onload method and is executed when entire page and resources have been loaded in the DOM.  If you run the above code you will get a Javascript alert box on document load.  Look at the structure of the document.ready, it accepts a method as a parameter.  Look between the method braces $(document).ready(function() { alert(“Welcome to JQuery”); }); function(){ alert(“Welcome to JQuery”);} 29

 By default, jQuery uses "$" as a shortcut for "jQuery“  $ is nothing but a shorthand notation for find method in JQuery. You can also use Jquery("") instead of $ ("") however use $ as it will be consistent.  $ accepts search selector. There are many search selector which helps in finding elements in DOM tree.  $ returns array of elements. 30

 ID selector. Find DOM element by ID. ID selector Syntax: $("#myDiv") selects element with ID myDIV. ID search requires # to be preFixed.  Element selector: Find all DOM element by element Type. Element selector: Syntax: $("div") selects all DIV in the dom tree. Notice no prefix used.  CSS selector: Find all element with a CSS class. CSS selector: Syntax: $(".myClass") select all element with myClass. CSS class requires a dot.  You can also mix and match.  $(“div.main”) // tag and class  $(“table#data”) // tag and id  $(“#content,.menu”) // find by id + by class  $(“h1, h2, h3, div.content”) // multiple combination  Read : 31

 Events in Jquery are bound to elements inside the document.ready method. The elements get bound when document.ready is fired.  $("a").click has 2 parts. 1st selector, 2nd event. The 1st part finds the element on which method is to be attached and 2nd part attaches method on the give event, in this example a Click.  Look at the syntax, event accepts a method as a parameter. $(document).ready(function() { $("a").click(function() { alert("Thanks for visiting!"); }); Read: 32

 jQuery abstracts events .click() .blur() .focus() .change()  Etc…  Attached via selectors  $( ).eventname( or inline);  $("a").click(function(){ $(this).addClass(‘red’);}); 33

.css(‘property’, ‘value’) .css({‘prop1’:‘value1’, ‘prop2’:’value2’…})  E.g..css(‘color’, ‘red’)  $(“div”).show(); // just show  $(“div”).show(“slow”); // reveal slowly, slow=600ms  $(“div”).hide(“fast”); // hide fast, fast=200ms  $(“div”).toggle(100); // hide or show in 100ms  $(“div”).slideUp();  $(“div”).slideDown(“fast”);  $(“div”).slideToggle(1000);  $(“div”).fadeIn(“fast”);  $(“div”).fadeOut(“normal”);  $(“div”).fadeTo (“fast”, 0.5); // fade to a custom opacity 34

 Example – Show/Hide the old way Click here to toggle visibility of #foo function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; }  Example – Show/Hide with jQuery $().ready(function(){ $("a").click(function(){ $("#more").toggle("slow"); return false; }); 35

 Jquery can have performance implication dependent on how you write code.  Generalization is good but excess is bad. Remember every $/Find search using attribute /element,parses the DOM for elements and excessive use can cause the browse to hang.  Use ID selector as much as possible or at least use nested selector using the ID as parent. To search all input element  $( " input " ) will perform slower than  $( " #tableName input " ) which will be faster.  Use JQuery methods only to change properties, get values and modify attribute s, to avoid cross browser issues.  Remember JQuery offers abstraction to provide a common interface for all cross browser method and members. 36

 – Book Website  - A guide to the basics of jQuery  - Learn how to make your websites interactive and create animations by using jQuery. 37