Top Banner
User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1 Friday, October 14, 11
22

User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

May 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

User Interaction:jQuery

Asst. Professor Donald J. PattersonINF 133 Fall 2011

1Friday, October 14, 11

Page 2: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• jQuery

• A JavaScript Library

• Cross-browser

• Free (beer & speech)

• It supports

•manipulating HTML elements (DOM)

• animations

• event handling

• AJAX

Friday, October 14, 11

Page 3: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

•Getting access to jQuery in our code

• You can’t just write JavaScript that calls jQuery

• You must load it

• From where?

• From your own machine

• http://jquery.com/

• From someone else’s machine

• From Google

•Why would you do this?

• http://code.google.com/apis/libraries/devguide.html

• Shortcut

Friday, October 14, 11

Page 4: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• Loading jQuery is just like loading a remote JavaScript

Friday, October 14, 11

Page 6: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

•With jQuery you select HTML elements in the DOM and perform actions on them

• Basic syntax is: $(selector).action()

• A dollar sign ($) to define jQuery

• $(selector).action() = jQuery(selector).action()

• A selector to "query (or find)" HTML elements

• A jQuery action to apply to the element(s)

w3schools

Friday, October 14, 11

Page 7: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

<p class=”foo”>words</p>

<p id=”bar”>more words</p>

<p class=”foo”>even more words</p>

<img class=”foo”/>

• Selection examples:

•multiple results

• $("p").hide()

• $(".foo").hide()

• $("p.foo").hide()

• single result

• $("#bar").hide()

• context dependent

• $(this).hide()

w3schools

Friday, October 14, 11

Page 8: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Possible Actions:

• append content to a DOM element

• wrap content around a DOM element

• toggle the display of a DOM element

• attach a function that is run when you hover over a DOM element

• you can request data via the ajax pattern

w3schools

Friday, October 14, 11

Page 11: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 12: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 13: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 14: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• Assignment 2

• Present the data as a table

• http://www.w3schools.com/html/html_tables.asp

• HTML tables overview

• 3 primary tags

• <table>

• <tr>

• <td>

Friday, October 14, 11

Page 15: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• Basic table

• <table>

• <tr>

• <td>

Friday, October 14, 11

Page 16: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• Assignment #2

•Geocoded Feeds

• http://api.flickr.com/services/feeds/geo/QDd_2PObCZ4ZsRM6Sw&format=json

• jQuery

• HTML Table

• AJAX request

Friday, October 14, 11

Page 17: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 18: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 19: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

• Assignment #2

•Geocoded Feeds

• http://api.flickr.com/services/feeds/geo/QDd_2PObCZ4ZsRM6Sw&format=json

• jQuery

• HTML Table

• AJAX request

• Cross-site scripting

• jsonP

Friday, October 14, 11

Page 20: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 21: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

jQuery

Friday, October 14, 11

Page 22: User Interaction: jQuery - Donald Bren School of ...djp3/classes/2011_09_INF133/Lectures/Lec… · User Interaction: jQuery Asst. Professor Donald J. Patterson INF 133 Fall 2011 1

Friday, October 14, 11