jQuery The Easy JavaScript Nikolay Chochev Technical Trainer

Slides:



Advertisements
Similar presentations
Getting Started with jQuery. 1. Introduction to jQuery 2. Selection and DOM manipulation Contents 2.
Advertisements

JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
CS428 Web Engineering Lecture 15 Introduction to Jquery.
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)
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Simon Amrein Consultant Trivadis AG What is ASP.NET 4.0 Ajax Ajax Control Toolkit Microsoft Ajax Content Delivery Network jQuery jQuery Client Templates.
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 the missing manual Chapter 11
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
13. jQuery See the official documentation at  See the terse API documentation at
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
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.
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.
. 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
Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
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.
JQuery Overview Unleash the Power of jQuery SoftUni Team Technical Trainers Software University
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.
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
SHAREPOINT & JQUERY. Hi, my name and I am a product manager at lightning tools. I have been working with SharePoint for 5 years.
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.
05 | Integrating JavaScript and MVC 4 Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
Agenda 1)Modern web standards overview 2)JavaScript library overview 3)Building a Single Page Application SPA.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
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.
MICROSOFT AJAX CDN (CONTENT DELIVERY NETWORK) Make Your ASP.NET site faster to retrieve.
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
SharePoint & jQuery. About me Phill Duffy – Product Manager at Lightning Tools Ltd – Author of ‘Pro SharePoint with jQuery’ – MCTS Application Developer.
JQuery Fundamentals Introduction Tutorial Videos
What is jQuery?.
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.
Tek Raj Chhetri Code for Humans not for machine.
Unleash the Power of jQuery
CGS 3066: Web Programming and Design Spring 2017
Introduction to Web programming
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
Fundamentals, DOM, Events, AJAX, UI
The Cliff Notes Version
JavaScript Introduction
JQuery with ASP.NET.
..
MIS JavaScript and API Workshop (Part 2)
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Getting started with jQuery
An introduction to jQuery
E-commerce Applications Development
An introduction to jQuery
Getting started with jQuery
An introduction to jQuery
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
JQuery.
Presentation transcript:

jQuery The Easy JavaScript Nikolay Chochev Technical Trainer http://chochev.eu

Table of Contents What is jQuery? jQuery Fundamentals AJAX Selectors DOM Manipulation Events and Chaining AJAX jQuery AJAX Methods Executing AJAX Requests

The world’s most popular JavaScript library What is jQuery? The world’s most popular JavaScript library

What is jQuery? jQuery is a cross-browser JavaScript library Designed to simplify the client-side scripting of HTML The most popular JavaScript library in use today Free, open source software jQuery's syntax is designed to make it easier to Navigate a document and select DOM elements Create animations Handle events Develop AJAX applications

What is jQuery? (2) jQuery also provides capabilities for developers to create plugins for Low-level interaction and animation Advanced effects and high-level, theme-able widgets Creation of powerful and dynamic web pages Microsoft adopted jQuery within Visual Studio Uses in Microsoft's ASP.NET AJAX Framework and ASP.NET MVC Framework

Why jQuery is So Popular? Easy to learn Fluent programming style Easy to extend You create new jQuery plugins by creating new JavaScript functions Powerful DOM Selection Powered by CSS 3.0 Lightweight Community Support Large community of developers and geeks

How to Add jQuery to a Web Site? Download jQuery files from http://www.jquery.com Self hosted You can choose to self host the .js file E.g. jquery-1.7.js or jquery-1.7.min.js Use it from CDN (content delivery network) Microsoft, jQuery, Google CDNs e.g. http://code.jquery.com/jquery-1.7.2.min.js, http://ajax.microsoft.com/ajax/jquery/jquery- 1.7.2.min.js Talking Points: You can choose to self host files - this is including jQuery in the scripts folder in Visual Studio. Can also just include jQuery from a CDN - simply change the script reference to point to jQuery on the CDN Can be faster loading and client browser may already have jQuery file cached Be careful! If the CDN goes down your site may also go down. Source version is human readable. Always include the minified version for your production code.

Fundamentals of jQuery Selecting, Adding, Removing DOM Elements

Selectors With jQuery we can select the HTML elements we want Using CSS-like selectors Selector can be any of the CSS selectors $("selector") //by tag $("div") //by class $(".menu-item") //by id $("#navigation") //by combination of selectors $("ul.menu li")

Selectors Live Demo

Selecting and Doing Something Selecting items with jQuery Almost always returns a collection of the items Even if there is only one item Can be stored in a variable or used right away // Finding the item $("#something").hide(); //var something=$("#something"); //something.hide(); // Doing something with the found item <div id="something"></div>

Show Hide Elements Live Demo

DOM Manipulation Adding elements can be done on the fly Very easily Can be appended to the page Or to another element $('<ul><li>Hello</li></ul>').appendTo('body'); $('<ul><li>Hello</li></ul>').appendTo('#pesho');

Removing Elements You can also remove elements from the DOM Just as easy // Before <div> <p>Red</p> <p>Green</p> </div> // Removing elements $('p').remove(); // After <div> </div>

Selecting Multiple Elements Live Demo Selecting Multiple Elements

jQuery Events With jQuery binding to events is very easy We can specify a click handler For example by using the click method The above code will bind the myClickHandler function to all anchors with a class of tab // Binding an event function() myClickHandler { // event handling code $(this).css('color', 'red'); }; $('a.tab').click(myClickHandler);

jQuery Events Functions in JavaScript could be anonymous This is the same exact functionality as the previous example In the previous example we polluted the global scope with a new function name Can be dangerous as someone could overwrite your function with their own, accidentally or not $('a.tab').click(function() { // event handling code $(this).css('color', 'red'); });

jQuery Events Live Demo

Binding Handlers Remember addEventListener and attachEvent? With jQuery this is unified by a register method Three such methods exist and all of the work on (jQuery 1.7, currently the method to use) bind (jQuery 1.4 +, deprecated in jQuery 1.7) live (jQuery 1.3 +, deprecated in jQuery 1.7) $(".buttons").on("click", function(){…}); $(".buttons").bind("click", function(){…}); $(".buttons").live("click", function(){…});

jQuery Binding Handlers Live Demo

jQuery Method Chaining Many methods allow chaining Chaining is where you can continue to "chain" on methods one after another As an example, the addClass method will add the class 'odd' in the code below Then return the jQuery collection We can immediately chain on the "click" event Click then operates on the odd rows by adding a click handler to each of them $('tr:odd').addClass('odd') .click(function () { alert('you clicked a tr!'); });

Chaining Methods Live Demo

Dynamically Assigning a Class

Assigning a Class Class can be assigned with the addClass() method removeClass() to remove the class $(".menu-item a").on("click",function(){ $(".selected").removeClass("selected"); $(this).addClass("selected"); }

Dynamically Assigning a Class Live Demo

jQuery Stack Architecture Some jQuery methods chain and return a new collection of elements 'Find' and 'Filter' are two examples jQuery holds on to the previous collections, essentially creating a stack set to store them

jQuery Stack Architecture (2) Methods like Find and Filter create a new collection which is added to the stack Older collections are pushed further 'downward' on the stack You can get a previous collection back from the stack by using the end() method $('body') // [body] .find('p') // [p, p, p] > [body] .find('a') // [a, a] > [p, p, p] > [body] .addClass('foo') .end() // [p, p, p] > [body] .end() // [body]

jQuery & Chaining and Architecture This is a popular use that shows both chaining and the stack architecture $('tr') .filter(':odd') .addClass('myOddClass') .end() .filter(':even') .addClass('myEvenClass');

jQuery & Chaining and Architecture (2) First select all rows Then filter to only the odd rows The odd rows are placed on the top of the stack The 'all rows' collection is now 'pushed downward' Add a class to the odd rows We call end Throws away the 'odd rows' collection Grabs the next element in the stack The 'all rows' collection Then filter to find even rows We add a class to the even rows

Introduction to JavaScript ? ? ? ? ? Questions? ? ? ? ? ? ?