JQuery Javascript Framework Aryo Pinandito. A Little Bit About jQuery  jQuery is an Open-Source JavaScript framework that simplifies cross-browser client.

Slides:



Advertisements
Similar presentations
JavaScript – Quiz #8 Lecture Code:
Advertisements

The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
Information Organization Lab Berkeley School of Information, Fall 2011.
JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
CS428 Web Engineering Lecture 15 Introduction to Jquery.
JAVASCRIPT Introduction Kenny Lam. What is Javascript?  Client-side scripting language that can manipulate elements in the DOM  Event-driven language.
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.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
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:
Javascript and the Web Whys and Hows of Javascript.
Getting Started.  jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions.
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
Nguyen Ich Cuong.  Course duration: 45’  Purpose: Present Introduction to JQuery  Targeted attendees: NICorp Trainee  Tests/quiz: Yes - 10’
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.
JavaScript & jQuery the missing manual Chapter 11
JQuery March 09 th,2009 Create by
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
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.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
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.
INFORMATION ORGANIZATION LAB SEPTEMBER 14, 2010 Overview of HTML, CSS, JavaScript, and jQuery. Introduction to browser extensions. Details about Project.
JQuery Fairway Code Brew. Agenda What is jQuery? No, really, what is it? Show me something cool Why should I use it? Disturbing photo More features FlexBox.
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
Department Name (View Master > Edit Slide 1) JQuery I took these slides from the site because they were pretty good looking.
Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
LOGO sparcs.org 1 jQuery Tutorial Presenter ㅎㅇㅎㅇ.
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.
Web Programming Language Week 9 Dr. Ken Cosh Introducing jQuery.
Creating Dynamic Webpages
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
Unit 13 –JQuery Basics Instructor: Brent Presley.
SHAREPOINT & JQUERY. Hi, my name and I am a product manager at lightning tools. I have been working with SharePoint for 5 years.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
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)
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
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.
Jquery is totally awesome.
JQuery Fundamentals Introduction Tutorial Videos
Vinay Vasyani Internet Programming
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.
Intro to jQuery jQuery is a popular, and extensible, JavaScript library Supports … DOM manipulation CSS manipulation HTML event methods Effects & animations.
Introduction to Web programming
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
Information Organization Lab
Web Programming Language
..
MIS JavaScript and API Workshop (Part 2)
E-commerce Applications Development
An introduction to jQuery
An introduction to jQuery
Web Client Side Technologies Raneem Qaddoura
Presentation transcript:

jQuery Javascript Framework Aryo Pinandito

A Little Bit About jQuery  jQuery is an Open-Source JavaScript framework that simplifies cross-browser client side scripting.  Animations  DOM manipulation  AJAX  Extensibility through plugins  jQuery was created by John Resig and released January 2006  Most current release is (2012)  What is jQuery?

Why should you use it?  Easy to learn! It uses CSS syntax for selection  Its tiny 252KB (32KB, minified and Gzipped)  Documented api.jquery.com & Supported forum.jquery.comapi.jquery.com forum.jquery.com  Cross browser compatibility: IE 6+, FF 2+  It is the most used JavaScript library on the web today  39% of all sites that use JavaScript use jQuery.  trends.builtwith.com/javascript/JQuery trends.builtwith.com/javascript/JQuery

PWNS All Other Frameworks

Who Uses jQuery? GoogleAmazonIBM MicrosoftTwitterDell docs.jquery.com/Sites_Using_jQuery

What is the DOM? Document Object Model (DOM): noun Blah blah blah long definition that makes little sense….

What Is The DOM?  Long story short, the DOM is your html document code. From the  to the  The DOM is loaded top to bottom, so include your scripts at the bottom of the page for best performance.  The DOM is "ready" when everything on the page has loaded.  Stylesheets  JavaScripts  Images

Wait!!  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 javascript/jQuery code here });

And What If I Don't Wanna, Huh? 1. Code doesn't work, throws an error (90%) 2. Code works… this page load, next page load see #1. (~9%) 3. Code opens a worm hole that transports your page back to 1990 revolutionizing the Web as we know it. While seemingly great, it also creates a paradox and destroys the universe. * (<1%)  *(has yet to be fully verified) 1 of 3 things will happen:

Loading jQuery  In order to use jQuery you need to load it.  You can include it locally on your own server:  Or use one of the CDN's made available:  ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js  ajax.microsoft.com/ajax/jquery/jquery js ajax.microsoft.com/ajax/jquery/jquery js  CDN's are Gzipped and minified

Load Scripts At The Bottom Problem: When scripts are downloading they block everything else in almost all browsers! Solution: Best practice: Load your scripts at the bottom of your page so they don't interrupt page content downloads.

jQuery = $  The dollar sign is a synonym for the jQuery function

And BOOM! Goes The Dynamite.  Html: Hello World! I'm Aryo  Script: $(function(){ $("p").addClass("isCool"); //keep telling yourself that.. });  Resulting html: Hello World! I'm Aryo

Break It Down Now! $(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.

All Your Basic Selectors Are Belong To Us  Uses the same syntax you use to style elements in CSS! $("p") $("div") $("#foo") id="foo" $(".foo") class="fo o" api.jquery.com/category/selectors/

 jQuery: $("p").addClass("sophisticated");  Before:  After: Get Classy

This Has No Class At All!  jQuery: $("p").removeClass("sophisticated");  Before:  After:

Hide and Seek  jQuery: $("div").show();  Before:  After:

I'm Not Lame, Am I?  jQuery: $("#aryo").text("Is Cool");  Before: Is Lame  After: Is Cool

You Can Chain Most Methods Together $("p").addClass("sophisticated").text("Hello World!").show(); "Daisy Chain!"

Some of Basic Methods 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/

Getters and Setters

Dual Purpose Methods Getter Setter $("#foo").text();$("#foo").text("foo");

Use jQuery To Get === "Panda" $("p").text();  Panda myVar === "Panda" myVar = $("p").text();

Use jQuery To Set BigPanda $("p").text("BigPanda");  Panda myVar === "BigPanda" BigPanda myVar = "BigPanda"; $("p").text(myVar);

jQuery: Get and Set Complete list at var a = $(‘a’).text(); $(‘a’).text(‘Hello world’); UC Berkeley var href = $(‘a’).attr(‘href’); $(‘a’).attr(‘href’, ‘

jQuery: Events General Eventsready, load, scroll Mouse Events click, hover, mouseenter, mouseleave Keyboard Eventskeypress, keydown, keyup Forms Eventssubmit, focus, blur Complete list at $(element).eventType(function(){ // JavaScript });

jQuery: Live Events $(‘li’).live(‘click’, function(){ // Do Something }); A normal event binding attaches to all matched elements when it is called. A live event calls the callback function when the event occurs on all matched element, current and future. $(‘li’).click(function(){ // Do something });

Click Events Are Awesome! $("#panda").click(function(){ $(this).text("Is Cool"); // this = #panda alert("Take that Zoo!"); }); $("#panda").click(function(event){ $(this).text("Is Cool"); // this = #panda alert("Take that Zoo!"); //Prevents default action event.preventDefault(); });

jQuery: Forms Complete list at See the documentation for.val() in particular: $(‘#name’).val(); $(‘#name’).val(‘Doe’); $(‘#name’).attr(‘value’); $(‘#name’).attr(‘value’, ‘Doe’);

jQuery: CSS Complete list at $(‘h1’).css(‘color’, ‘red’); $(‘h1’).addClass(‘important’); Hello world $(‘h1’).hide(); $(‘h1’).fadeIn();

“this” in JavaScript var person = { name: 'Mohit', sayHello: function(){ alert('Hello, ' + this.name); } } this is a special variable. It is the object in the current context.

$('li').click(function(){ this // DOM element $(this) // jQuery object }); “this” in jQuery $('li').click(function(){ $('li').hide(); });

Plugins

Viva Variety!  "If you want to create an animation, effect or UI component, chances are pretty good that someone has done your work for you already.”  -Eric Steinborn 2010  plugins.jquery.com plugins.jquery.com

AJAX and Cross-site Scripting  Web 2.0 FTW  Web 3.0? – More Semantic!

AJAX What?  Asynchronous  Javascript  and  XmlHttpRequest

AJAX What? $.get(' function(xml){ console.log(xml); });

same-origin policy  (Alas, no cross-site scripting!)

Cross-site scripting Workarounds Proxy server JSONP Trusted contexts Evil.com Normal WebpageAJAX

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; });

Example – Ajax the Old Way function GetXmlHttpObject(handler) { var objXmlHttp = null; //Holds the local xmlHTTP object instance //Depending on the browser, try to create the xmlHttp object if (is_ie){ var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; try{ objXmlHttp = new ActiveXObject(strObjName); objXmlHttp.onreadystatechange = handler; } catch(e){ //Object creation errored alert('Verify that activescripting and activeX controls are enabled'); return; } else{ // Mozilla | Netscape | Safari objXmlHttp = new XMLHttpRequest(); objXmlHttp.onload = handler; objXmlHttp.onerror = handler; } //Return the instantiated object return objXmlHttp; }

Example – Ajax with jQuery $.get(“controller/actionname", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); }); $.post(“controller/actionname", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); });

Example – Form Validation $().ready(function(){ // validate the comment form when it is submitted $("#commentForm").validate(); });

Great References  John Resig's introduction slides John Resig's introduction slides  jQuery 1.4 Cheat Sheet jQuery 1.4 Cheat Sheet  jQuery API jQuery API  jQuery Forums jQuery Forums  YAYquery Podcast (explicit) YAYquery Podcast (explicit)

Questions?