An introduction to jQuery

Slides:



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

Getting Started with jQuery. 1. Introduction to jQuery 2. Selection and DOM manipulation Contents 2.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
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
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.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
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.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
INTRODUCTION ABOUT DIV Most websites have put their content in multiple columns. Multiple columns are created by using or elements. The div element is.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
JQuery Fundamentals Introduction Tutorial Videos
Brad N Greenwood, PhD MBA
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Learning to Program D is for Digital.
Sessions and cookies (part 2)
Introduction to Web programming
Form Data (part 1) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
The Cliff Notes Version
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
Introduction to JavaScript
Introduction to AJAX MIS 3502 Jeremy Shafer Department of MIS
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
A second look at JavaScript
Getting started with jQuery
Organize your code with MVC
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
A (gentle???) Introduction to JavaScript
JQuery with ASP.NET.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
..
Sending a text message (and more)
Form Validation (with jQuery, HTML5, and CSS)
Form Validation, Part 2 (with jQuery, HTML5, and CSS)
JavaScript and the DOM MIS 2402 Jeremy Shafer Department of MIS
Numbers, strings and dates in JavaScript
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
MIS JavaScript and API Workshop (Part 3)
Introduction to AJAX and JSON
An Introduction to Animation
MIS JavaScript and API Workshop (Part 2)
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Programming Control Structures with JavaScript Part 2
Getting started with jQuery
E-commerce Applications Development
Loops and Arrays in JavaScript
JavaScript objects, functions, and events
Form Data (part 1) MIS3501 Jeremy Shafer Department of MIS
Introduction to JavaScript
An introduction to jQuery
Getting started with jQuery
An introduction to jQuery
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Web Client Side Technologies Raneem Qaddoura
Sending a text message (and more)
Strings and Dates in JavaScript
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Single Page Architecture (SPA)
Web Programming and Design
Murach's JavaScript and jQuery (3rd Ed.)
JavaScript and the DOM MIS 2402 Maxwell Furman Department of MIS
Presentation transcript:

An introduction to jQuery Jeremy Shafer Department of MIS Fox School of Business Temple University

Objectives Describe jQuery. Describe how to include the jQuery library in your web pages. Understand the role of jQuery selectors, methods, and events. Repeat and recall the syntax of a simple jQuery selector. Repeat and recall the syntax of the html and append jQuery methods . Apply the pattern of jQuery syntax to val and other new methods.

How do I get jQuery? Surprise! You have had jQuery available to you for most of the semester. Try opening hello.html (in intro_jquery.zip) in Chrome. Try opening it with and without line 9.

Linking to the jQuery library Pro tip! Knowing what a CDN URL is, and how to add one to your solution, is a powerful way to extend the options available to you, the programmer.

jQuery Described So… Just like Bootstrap is a framework created to simplify CSS, jQuery is a library created to simplify JavaScript. It’s the same sort of idea: make the developer’s life easier, not harder! jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. jQuery is the most popular JavaScript library in use today. jQuery is free, open-source software licensed under the MIT License. Initial release date: August 26, 2006; 13 years ago Created by American software engineer and entrepreneur, John Resig. John Resig is an alumni of the Rochester Institute of Technology. He was going to call it jSelect, but that name was already taken. That would have been a *great* name, because “selecting” is a fundamental concept in jQuery

What do you mean by “selecting”? jQuery relies heavily on the notion of selecting. Recall this example from last week. When we say: $('#mymessage').html('Hello world!’); The browser selects the tag with the id “mymessage” #mymessage is called the selector ! We take action on the tags found. So, the basic structure of a jQuery command is: $(“some selector goes here”).SomeMethod();

jQuery selectors DISCUSS: These are the most simple examples of jQuery selectors. What does this syntax/convention remind you of?

Once you find the tag(s) Again, the basic structure of a jQuery command is: $(“some selector goes here”).SomeMethod(); Here’s a new, useful, jQuery method: .addClass("css class name"); DISCUSS: What are two jQuery methods that you have already used this semester? (Use this to add a existing css class to a tag or tags!) This methods and others can work on multiple elements. The jQuery methods work on *all the elements* returned by a selector. (And you don’t even need to write a loop to do it!) Use hello02.html to demonstrate the addClass method, and different selectors

More useful jQuery methods .removeClass("css class name") .toggleClass("css class name") .html(value) .append(value) .val() .val(value) Remove a css class Toggle a css class Putting content in to a tag Retrieve and assign the value of a tag Let’s see jQuery at work! (see hello03.html through hello05.html)

Make sure you catch this… Notice that we are passing “30” into the value of the #gallons tag. Here, #gallons is the id of an <input> tag. We assign the value 30 that by passing is as an argument to the val method. We don’t use the assignment operator ( = ) here!

$(“some selector goes here”).next().SomeMethod(); The next() method Here’s our last method for the day … the next() method. What makes this method interesting is that it used in conjunction with other jQuery elements as follows: $(“some selector goes here”).next().SomeMethod(); The next() method allows us to manipulate the tag that is next to the selected tag. This technique of using two or more methods together is called chaining. Let’s see hello06.html

Events (again)

Events (again) – the jQuery ready event I will do it this way.

Events (again) – the jQuery click event

Why this is a big deal… Way back at the beginning of the semester we said that JavaScript could be used to manipulate the HTML and CSS in the browser in response to an event. We’ve arrived! That’s what we’ve been doing today! HTML CSS JavaScript

jQuery Summary Methods Selectors .html() . for classes .append() .val() .addClass() .removeClass() .toggleClass() .next() Selectors . for classes # for id No prefix for tags Events .ready() .click() We will use these as our core jQuery functions. When we need to add a new event or method we’ll draw your attention to it!

Next time… Next time we meet, we will use JavaScript and our new jQuery building blocks to create a user interface. We will be working with HTML forms, collecting data, checking the data, and changing the appearance of the page based on what the user does. At last! We have all the pieces we need to do this!