1. Trang chủ
  2. » Công Nghệ Thông Tin

Learning jquery lesson

54 250 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 54
Dung lượng 615 KB

Nội dung

Learning jQuery Learning jQuery Giuseppe Attardi Giuseppe Attardi Università di Pisa Università di Pisa Some slides from: BreadFish JavaScript JavaScript  A script language that interpreted by A script language that interpreted by browser browser  OOP OOP  Dynamic typing Dynamic typing  Run-time evaluation Run-time evaluation JavaScript JavaScript  Cannot access host computer (except cookie) Cannot access host computer (except cookie)  Same origin policy Same origin policy  Non-persistence Non-persistence  Cannot access history object Cannot access history object  Cannot write the value of file upload field Cannot write the value of file upload field JavaScript Libraries JavaScript Libraries  jQuery jQuery  Mootools Mootools  Prototype Prototype  YUI YUI Introduction to jQuery Introduction to jQuery  Developed in 2006 by Developed in 2006 by John Resig John Resig at Rochester at Rochester Institute of Technology Institute of Technology  jQuery is a lightweight jQuery is a lightweight JavaScript library JavaScript library that that emphasizes interaction between emphasizes interaction between JavaScript JavaScript and and HTML HTML  jQuery is jQuery is free, open source software free, open source software Dual-licensed Dual-licensed under the under the MIT License MIT License and the and the GNU General Public License GNU General Public License  Helps web developers to create simple pieces of Helps web developers to create simple pieces of interaction without being forced to write long, interaction without being forced to write long, complex, book-length pieces of code complex, book-length pieces of code Introduction to jQuery Introduction to jQuery  Why do I want it Why do I want it  Rich Internet Applications (RIA)  Dynamic HTML (DHTML)  How do I get it How do I get it  www.jquery.com  How can I learn it How can I learn it  jQuery in Action by Bibeault & Katz, Manning  jQuery Visual Quickstart Guide by Holzner, Peachpit  www.jquery.com  docs.jquery.com  www.visualjquery.com  www.Jqueryfordesigners.com  www.gscottolson.com/weblog/ - cheat sheet  www.javascripttoolbox.com/jquery Summary Summary  Introduction, installation, “Howdy World”, Ready Introduction, installation, “Howdy World”, Ready function, DOM, Selecting and Formatting web function, DOM, Selecting and Formatting web page elements page elements  Events and Animations Events and Animations  jQuery Plugin libraries jQuery Plugin libraries  AJAX with PHP and ASP.NET AJAX with PHP and ASP.NET Introduction to jQuery Introduction to jQuery  Installation Installation  just download the jquery-1.x.x.js file and put it in your website folder  Using jQuery Using jQuery  Visual Web Developer Express Edition  Expression Web What jQuery Does What jQuery Does  “ “ Unobtrusive” JavaScript Unobtrusive” JavaScript  separation of behavior from structure  CSS CSS  separation of style from structure  Allows adding JavaScript to your web pages Allows adding JavaScript to your web pages  Advantages over Advantages over just just JavaScript JavaScript  Much easier to use  Eliminates cross-browser problems 5 Things jQuery Provides 5 Things jQuery Provides  Select DOM (Document Object Model) elements Select DOM (Document Object Model) elements on a page – one element or a group of them on a page – one element or a group of them  Set properties of DOM elements, in groups (“Find Set properties of DOM elements, in groups (“Find something, do something with it”) something, do something with it”)  Creates, deletes, shows, hides DOM elements Creates, deletes, shows, hides DOM elements  Defines event behavior on a page (click, mouse Defines event behavior on a page (click, mouse movement, dynamic styles, animations, dynamic movement, dynamic styles, animations, dynamic content) content)  AJAX calls AJAX calls [...]... Extending jQuery  Creating a jQuery function jQuery Plugins (UI Library) Tab example  Slider example  Carousel example  Photomatic example  jQuery Core  jQuery( selector, [ context ]): Accepts a string containing a CSS selector which is then used to match a set of elements and returns a jQuery object      jQuery( element) jQuery( elementArray) jQuery( jQuery object) jQuery( ) can be written as $() jQuery. .. programming language in use.” Wikipedia The jQuery Function        jQuery( ) = $() $(function) The “Ready” handler $(‘selector’) Element selector expression $(element) Specify element(s) directly $(‘HTML’) HTML creation $.function() Execute a jQuery function $.fn.myfunc(){} Create jQuery function The Ready Function Set up a basic HTML page and add jQuery  Create a “ready” function  Call a function... The Ready Function Set up a basic HTML page and add jQuery  Create a “ready” function  Call a function  5 ways to specify the ready function       jquery( document).ready(function(){…};); jquery( ).ready(function(){…};) jquery( function(){…};) jquery( dofunc); $(dofunc); Selecting Elements Creating a “wrapped set” $(selector)  selector:                   $(‘#id’) id of element... printhello(){ $(“#hello”).html(“Hello, jQuery! ”); } $(document).ready(printhello());  Same as window.onload??? js $(document).ready(function(){ $(“#hello”).html(“Hello, jQuery! ”); }); jQuery Events           bind() blur() change() click() focus() hover() select() toggle() trigger() submit()  mousedown()  mouseenter()  mouseleave()  keypress()  keyup() jQuery Events $(document).keyup(function(event)...The DOM      Document Object Model jQuery is “DOM scripting” Heirarchal structure of a web page You can add and subtract DOM elements on the fly You can change the properties and contents of DOM elements on the fly The DOM “a cross-platform... having an alt attribute elements with an href attribute starting with ‘http://’ elements with an href attribute ending with ‘.pdf’ elements with an href attriute containing ‘ntpcug’ Useful jQuery Functions each() size() end() get(n) eq(n) slice(n,m) not(‘p’) add(‘p’) remove() empty() filter(fn/sel) find(selector) parent() children() next() prev() siblings() iterate over the set number of... mouseleave()  keypress()  keyup() jQuery Events $(document).keyup(function(event) { switch(event.which) { case 32: alert(“32 pressed”); break; } });  event.preventDefault()  event.stopPropagation() jQuery Selectors  follows CSS1~3 Selectors http://www.w3.org/TR/css3-selectors :animated  :has()  :gt()  . I learn it  jQuery in Action by Bibeault & Katz, Manning  jQuery Visual Quickstart Guide by Holzner, Peachpit  www .jquery. com  docs .jquery. com  www.visualjquery.com  www.Jqueryfordesigners.com  www.gscottolson.com/weblog/. jQuery  Installation Installation  just download the jquery- 1.x.x.js file and put it in your website folder  Using jQuery Using jQuery  Visual Web Developer Express Edition  Expression Web What jQuery Does What jQuery Does  “ “ Unobtrusive”. Learning jQuery Learning jQuery Giuseppe Attardi Giuseppe Attardi Università di Pisa Università di Pisa Some

Ngày đăng: 24/10/2014, 11:51