jquery 1.4 reference guide

336 880 0
jquery 1.4 reference guide

Đ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

www.it-ebooks.info jQuery 1.4 Reference Guide A comprehensive exploration of the popular JavaScript library Karl Swedberg Jonathan Chaffer BIRMINGHAM - MUMBAI www.it-ebooks.info jQuery 1.4 Reference Guide Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: January 2010 Production Reference: 1190110 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-84951-004-2 www.packtpub.com Cover Image by Karl Swedberg (karl@englishrules.com) www.it-ebooks.info Credits Authors Karl Swedberg Jonathan Chaffer Reviewers Joydip Kanjilal Dave Methvin Acquisition Editor Swapna V. Verlekar Development Editor Swapna V. Verlekar Technical Editor Tariq Rakhange Copy Editor Sneha Kulkarni Indexer Hemangini Bari Production Editorial Manager Abhijeet Deobhakta Editorial Team Leader Mithun Sehgal Project Team Leader Lata Basantani Project Coordinator Joel Goveya Proofreader Chris Smith Graphics Nilesh R. Mohite Production Coordinator Dolly Dasilva Cover Work Dolly Dasilva www.it-ebooks.info About the Authors Karl Swedberg is a web developer at Fusionary Media in Grand Rapids, Michigan, where he spends much of his time solving problems with JavaScript and implementing design. A member of the jQuery Project Team and an active contributor to the jQuery discussion list, Karl has presented at workshops and conferences, and provided corporate training in Europe and North America. Before he got hooked on to web development, Karl worked as a copy editor, a high-school English teacher, and a coffee house owner. He gave up his dream of becoming a professional musician in the early 1990s about the same time that he stumbled into a job at Microsoft in Redmond, Washington. He sold his hollow-body Rickenbacker ages ago, but still keeps an acoustic guitar in the basement. I wish to thank my wife, Sara, for keeping me sane. Thanks also to my two delightful children, Benjamin and Lucia. Jonathan Chaffer has my deepest respect for his programming expertise and my gratitude for his willingness to write this book with me. Many thanks to John Resig for creating the world's greatest JavaScript library and for fostering an amazing community around it. Thanks also to the folks at Packt Publishing, the technical reviewers of this book, the jQuery Cabal, and the many others who have provided help and inspiration along the way. www.it-ebooks.info Jonathan Chaffer is a member of Rapid Development Group, a web development rm located in Grand Rapids, Michigan. His work there includes overseeing and implementing projects in a wide variety of technologies, with an emphasis on PHP, MySQL, and JavaScript. In the open source community, Jonathan has been very active in the Drupal CMS project, which has adopted jQuery as its JavaScript framework of choice. He is the creator of the Content Construction Kit, a popular module for managing structured content on Drupal sites. He is responsible for major overhauls of Drupal's menu system and developer API reference. Jonathan lives in Grand Rapids with his wife, Jennifer. I would like to thank Jenny for her tireless enthusiasm and support, Karl for the motivation to continue writing when the spirit was weak, and the Ars Technica community for constant inspiration toward technical excellence. www.it-ebooks.info About the Reviewers Joydip Kanjilal is a Microsoft MVP in ASP.NET, and the author of a number of books on .NET and its related technologies. He has over 12 years of industry experience in IT with more than 6 years in Microsoft .NET and its related technologies. He has authored a lot of articles for some of the most reputable sites such as www.asptoday.com, www.devx.com, www.aspalliance.com, www.aspnetpro.com, www.mcpressonline.com, www.sql-server-performance. com, www.sswug.com, and so on. A lot of these articles have been selected at www.asp.net—Microsoft's ofcial site on ASP.NET. Joydip was also a community credit winner at www.community-credit.com a number of times. Joydip was also selected as MSDN Featured Developer of the Fortnight in November and December, 2008. Joydip has authored the following books: • ASP.NET 4.0 Programming (Mc-Graw Hill Publishing) • Entity Framework Tutorial (Packt Publishing) • Pro Sync Framework (APRESS) • Sams Teach Yourself ASP.NET Ajax in 24 Hours (Sams Publishing) • ASP.NET Data Presentation Controls Essentials (Packt Publishing) He is currently working as an independent software consultant and author. He has years of experience in designing and architecting solutions for various domains. His technical strengths include C, C++, VC++, Java, C#, Microsoft .NET, AJAX, Design Patterns, SQL Server, Operating Systems, and Computer Architecture. Joydip blogs at http://aspadvice.com/blogs/joydip and spends his time reading books, blogs, and writing books and articles. His hobbies include watching cricket, soccer, and playing chess. www.it-ebooks.info Dave Methvin is the Chief Technology Ofcer at PC Pitstop and one of the founding partners of the company. He provides technical direction for the PCPitstop. com (http://www.pcpitstop.com/) web site and oversees software development. Before joining PC Pitstop, Dave had an extensive career in computer journalism. He served as an Executive Editor at both Windows Magazine and PC Tech Journal, co-authored a book on Windows NT networking, and wrote articles for more than two dozen publications. Dave blogs on Windows issues for the InformationWeek (http://www.informationweek.com) web site. Dave holds both a bachelor's and a master's degree in Computer Science from the University of Virginia. He has been active in the jQuery community since 2006 and has written several popular plug-ins such as Splitter. www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Anatomy of a jQuery Script 7 A dynamic table of contents 7 Obtaining jQuery 8 Setting up the HTML document 9 Writing the jQuery code 11 Script dissection 12 Selector expressions 12 DOM traversal methods 13 DOM manipulation methods 13 Event methods 14 Effect methods 14 AJAX methods 15 Miscellaneous methods 15 Plug-in API 16 Summary 16 Chapter 2: Selector Expressions 17 CSS selectors 17 Element (T) 17 ID (#myid) 18 Class (.myclass) 18 Descendant (E F) 19 Child (E > F) 20 Adjacent sibling (E + F) 20 General sibling (E ~ F) 21 Multiple expressions (E, F, G) 22 Numbered child (:nth-child(n/even/odd/expr)) 22 First child (:rst-child) 24 www.it-ebooks.info [...]... Methods Properties jQuery documentation JavaScript reference JavaScript code compressors JavaScript code decompressors (X)HTML reference CSS reference Useful blogs Web development frameworks using jQuery Tools for Firefox Tools for Internet Explorer Tools for Safari Tools for Opera Other tools [ viii ] www.it-ebooks.info 265 268 281 283 284 285 286 286 287 287 289 291 292 293 294 294 Preface jQuery is a powerful,... inconsistencies and greatly reducing development time In jQuery 1.4 Reference Guide, you can investigate this library's features in a thorough, accessible format This book offers an organized menu of every jQuery method, function, and selector Entries are accompanied by detailed descriptions and helpful recipes that will assist you in getting the most out of jQuery, and avoiding the pitfalls commonly associated... related to jQuery, JavaScript, and web development in general Appendix B, Development Tools, recommends a number of useful third-party programs and utilities for editing and debugging jQuery code within your personal development environment What you need for this book This book is a reference guide, not a tutorial As such, prior exposure to the jQuery library will be beneficial in navigating this reference. .. Chapter 9, jQuery Properties, lists properties of the jQuery object that can be inspected for information about the browser environment With the catalog of built-in functionality concluded, we'll dive into the extension mechanisms jQuery makes available Chapter 10, Plug-in API, reveals these powerful ways to enhance jQuery' s already robust capabilities using a plug-in Chapter 11, Alphabetical Quick Reference, ... more, the book shows you how to cook up your own extensions with jQuery' s elegant plug-in architecture You'll discover the untapped possibilities that jQuery makes available and hone your skills as you return to this guide time and again What this book covers In Chapter 1, Anatomy of a jQuery Script, we'll begin by dissecting a working jQuery example This script will serve as a roadmap for this book,... should walk through the environment in which the script resides Obtaining jQuery The official jQuery web site (http:/ /jquery. com/) is always the most up-to-date resource for code and news related to the library To get started, we need a copy of jQuery, which can be downloaded right from the front page of the site Several versions of jQuery may be available at any given moment; the most appropriate for... version of jQuery is 1.4 No installation is required To use jQuery, we just need to place it on our site in a web-accessible location As JavaScript is an interpreted language, there is no compilation or build phase to worry about Whenever we need a page to have jQuery available, we will simply refer to the file's location from the HTML document with a tag as follows: . 13 7 .die() 13 9 Document loading 14 0 .ready() 14 0 .load() 14 1 .unload() 14 3 .error() 14 4 Mouse events 14 4 .mousedown() 14 5 .mouseup() 14 6 .click() 14 8 .dblclick() 14 9 .toggle() 15 1 .mouseover() 15 2 .mouseout(). 11 1 .insertBefore() 11 2 .after() 11 4 .insertAfter() 11 5 DOM insertion, around 11 7 .wrap() 11 7 .wrapAll() 11 8 .wrapInner() 11 9 DOM copying 12 1 .clone() 12 1 DOM removal 12 2 .empty() 12 2 .remove() 12 3 .detach() 12 5 .unwrap(). (getter) 10 1 .val() (setter) 10 1 .replaceWith() 10 2 .replaceAll() 10 3 DOM insertion, inside 10 4 .prepend() 10 4 .prependTo() 10 6 .append() 10 8 .appendTo() 10 9 DOM insertion, outside 11 1 .before() 11 1 .insertBefore()

Ngày đăng: 24/04/2014, 15:23

Từ khóa liên quan

Mục lục

  • Packt - jQuery 1.4 Reference Guide (January 2010) (ATTiCA)

  • Credits

  • About the Authors

  • About the Reviewers

  • Table of Contents

  • Preface

  • Chapter 1: Anatomy of a jQuery Script

    • A dynamic table of contents

      • Obtaining jQuery

      • Setting up the HTML document

      • Writing the jQuery code

    • Script dissection

      • Selector expressions

      • DOM traversal methods

      • DOM manipulation methods

      • Event methods

      • Effect methods

      • AJAX methods

      • Miscellaneous methods

      • Plug-in API

    • Summary

  • Chapter 2: Selector Expressions

    • CSS selectors

      • Element (T)

      • ID (#myid)

      • Class (.myclass)

      • Descendant (E F)

      • Child (E > F)

      • Adjacent sibling (E + F)

      • General sibling (E ~ F)

      • Multiple expressions (E, F, G)

      • Numbered child (:nth-child(n/even/odd/expr))

      • First child (:first-child)

      • Last child (:last-child)

      • Only child (:only-child)

      • Not (:not(E))

      • Empty (:empty)

      • Universal (*)

    • Attribute selectors

      • Attribute ([foo])

      • Attribute equals ([foo=bar])

      • Attribute does not equal ([foo!=bar])

      • Attribute begins with ([foo^=bar])

      • Attribute ends with ([foo$=bar])

      • Attribute contains ([foo*=bar])

      • Attribute contains word ([foo~=bar])

      • Attribute contains prefix ([foo|=bar])

    • Form selectors

    • Custom selectors

      • Element at index (:eq(n))

      • Greater than (:gt(n))

      • Less than (:lt(n))

      • First (:first)

      • Last (:last)

      • Even element (:even)

      • Odd element (:odd)

      • Is parent (:parent)

      • Contains text (:contains(text))

      • Contains element (:has(E))

      • Visible (:visible)

      • Hidden (:hidden)

      • Header element (:header)

      • Currently animating (:animated)

  • Chapter 3: DOM Traversal Methods

    • The jQuery function

      • $()

    • Filtering methods

      • .filter()

      • .not()

      • .has()

      • .eq()

      • .first()

      • .last()

      • .slice()

    • Tree traversal methods

      • .find()

      • .children()

      • .parents()

      • .parentsUntil()

      • .parent()

      • .closest()

      • .offsetParent()

      • .siblings()

      • .prev()

      • .prevAll()

      • .prevUntil()

      • .next()

      • .nextAll()

      • .nextUntil()

    • Miscellaneous traversal methods

      • .add()

      • .is()

      • .end()

      • .andSelf()

      • .map()

      • .contents()

  • Chapter 4: DOM Manipulation Methods

    • General attributes

      • .attr() (getter)

      • .attr() (setter)

      • .removeAttr()

    • Style properties

      • .css() (getter)

      • .css() (setter)

      • .height() (getter)

      • .height() (setter)

      • .innerHeight()

      • .outerHeight()

      • .width() (getter)

      • .width() (setter)

      • .innerWidth()

      • .outerWidth()

      • .offset() (getter)

      • .offset() (setter)

      • .position()

      • .scrollTop() (getter)

      • .scrollTop() (setter)

      • .scrollLeft() (getter)

      • .scrollLeft() (setter)

    • Class attributes

      • .hasClass()

      • .addClass()

      • .removeClass()

      • .toggleClass()

    • DOM replacement

      • .html() (getter)

      • .html() (setter)

      • .text() (getter)

      • .text() (setter)

      • .val() (getter)

      • .val() (setter)

      • .replaceWith()

      • .replaceAll()

    • DOM insertion, inside

      • .prepend()

      • .prependTo()

      • .append()

      • .appendTo()

    • DOM insertion, outside

      • .before()

      • .insertBefore()

      • .after()

      • .insertAfter()

    • DOM insertion, around

      • .wrap()

      • .wrapAll()

      • .wrapInner()

    • DOM copying

      • .clone()

    • DOM removal

      • .empty()

      • .remove()

      • .detach()

      • .unwrap()

  • Chapter 5: Event Methods

    • Event handler attachment

      • .bind()

      • .unbind()

      • .one()

      • .trigger()

      • .triggerHandler()

      • .live()

      • .die()

    • Document loading

      • .ready()

      • .load()

      • .unload()

      • .error()

    • Mouse events

      • .mousedown()

      • .mouseup()

      • .click()

      • .dblclick()

      • .toggle()

      • .mouseover()

      • .mouseout()

      • .mouseenter()

      • .mouseleave()

      • .hover()

      • .mousemove()

    • Form events

      • .focus()

      • .blur()

      • .change()

      • .select()

      • .submit()

    • Keyboard events

      • .keydown()

      • .keypress()

      • .keyup()

    • Browser events

      • .resize()

      • .scroll()

  • Chapter 6: Effect Methods

    • Pre-packaged effects

      • .show()

      • .hide()

      • .toggle()

      • .slideDown()

      • .slideUp()

      • .slideToggle()

      • .fadeIn()

      • .fadeOut()

      • .fadeTo()

    • Customized effects

      • .animate()

      • .stop()

      • .delay()

      • .queue()

      • .dequeue()

      • .clearQueue()

  • Chapter 7: AJAX Methods

    • Low-level interface

      • $.ajax()

      • $.ajaxSetup()

    • Shorthand methods

      • $.get()

      • .load()

      • $.post()

      • $.getJSON()

      • $.getScript()

    • Global AJAX event handlers

      • .ajaxComplete()

      • .ajaxError()

      • .ajaxSend()

      • .ajaxStart()

      • .ajaxStop()

      • .ajaxSuccess()

    • Helper functions

      • .serialize()

      • .serializeArray()

  • Chapter 8: Miscellaneous Methods

    • Setup methods

      • $.noConflict()

    • DOM element methods

      • .size()

      • .get()

      • .index()

    • Collection manipulation

      • .each()

      • $.grep()

      • $.makeArray()

      • $.inArray()

      • $.map()

      • $.merge()

      • $.unique()

      • $.extend()

      • $.trim()

      • $.param()

    • Introspection

      • $.isArray()

      • $.isFunction()

      • $.isPlainObject()

      • $.isEmptyObject()

      • $.isXMLDoc()

    • Data storage

      • .data()

      • .removeData()

  • Chapter 9: jQuery Properties

    • Global properties

      • $.browser

      • $.support

        • $.support.boxModel

        • $.support.cssFloat

        • $.support.hrefNormalized

        • $.support.htmlSerialize

        • $.support.leadingWhitespace

        • $.support.noCloneEvent

        • $.support.objectAll

        • $.support.opacity

        • $.support.scriptEval

        • $.support.style

        • $.support.tbody

    • jQuery object properties

      • .length

      • .selector

      • .context

  • Chapter 10: The Plug-in API

    • Using a plug-in

    • Developing a plug-in

      • Object method

      • Global function

      • Selector expression

    • Plug-in conventions

      • Use of the $ alias

      • Naming conventions

      • API standardization

  • Chapter 11: Alphabetical Quick Reference

    • Selector expressions

    • Methods

    • Properties

  • Appendix A: Online Resources

    • jQuery documentation

    • JavaScript reference

    • JavaScript code compressors

    • JavaScript code decompressors

    • (X)HTML reference

    • CSS reference

    • Useful blogs

    • Web development frameworks using jQuery

  • Appendix B: Development Tools

    • Tools for Firefox

    • Tools for Internet Explorer

    • Tools for Safari

    • Tools for Opera

    • Other tools

  • Index

  • Thank you

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan