Home > Store

Learning jQuery: A Hands-on Guide to Building Rich Interactive Web Front Ends

Register your product to gain access to bonus material or receive a coupon.

Learning jQuery: A Hands-on Guide to Building Rich Interactive Web Front Ends

eBook

  • Your Price: $30.39
  • List Price: $37.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2013
  • Dimensions: 7" x 9"
  • Edition: 1st
  • eBook
  • ISBN-10: 0-13-293155-9
  • ISBN-13: 978-0-13-293155-7

Get started fast with jQuery web programming

The jQuery JavaScript library greatly simplifies the creation of modern, rich web applications, while seamlessly integrating with virtually all leading web development platforms and frameworks. Learning jQuery will guide you through using jQuery, jQuery UI, and jQuery Mobile in your own projects. One step at a time, you’ll learn how to do everything from adding simple effects through building complete rich Internet applications.

This code-rich tutorial is designed for every working web developer. After clearly explaining all the basics, Ralph Steyer shows how to apply jQuery to create effects, animations, slideshows, lists, drag-and-droppable elements, interactive forms, and much more.

If you’re a web developer with  even basic JavaScript experience, Learning jQuery is your fastest route to success with jQuery

  

• Discover what jQuery can do, and how it works with JavaScript and DOM

• Select components to support dynamic processes

• Manipulate web page content and structure

• Apply and change formatting with CSS style sheets through jQuery

• Handle complex events more effectively and reliably

• Generate time-dependent and time-independent CSS effects

• Expand jQuery’s capabilities with plug-ins

• Use jQuery to create simpler, better, more powerful AJAX code

• Master powerful, flexible jQuery UI plug-ins for visual control and user interaction

• Simplify the creation of jQuery UI interfaces  with ThemeRoller

• Master basic rules for successfully working  with components and widgets

• Construct touch-enabled mobile front ends  with jQuery Mobile


Sample Content

Table of Contents

1 Introduction 1

    1.1 What Is This Book About? 2

        1.1.1 What You Can Learn from This Book 4

    1.2 Writing Conventions 5

    1.3 Who Is the Target Audience for This Book? 6

    1.4 What Do You Need? 6

        1.4.1 Hardware and Operating System 6

        1.4.2 jQuery and jQuery UI 7

        1.4.3 The Browsers 9

        1.4.4 Different Operating Systems and Virtual Machines for Testing 10

        1.4.5 The Web Server for Realistic Testing 11

        1.4.6 The Development Tools 13

    1.5 About the Author 16

2 First Examples with jQuery 17

    2.1 Accessing Elements and Protecting the DOM 17

    2.2 Editing the Web Page with DHTML à la jQuery 22

    2.3 Animatedly Reducing and Enlarging of an Element 25

    2.4 Changing Attributes Dynamically 28

3 Basic Knowledge 31

    3.1 The Web, Web 2.0, and the Client/Server Principle on the Internet 32

        3.1.1 Programming on the Web 32

        3.1.2 The Web 2.0 33

    3.2 JavaScript and Its Relationship to jQuery 33

        3.2.1 The General Integration of JavaScript in Websites 34

    3.3 AJAX and XMLHttpRequest (XHR) 37

        XML 38

        JSON 41

        More Details on Processing JSON for JavaScript Pros 43

    3.4 DOM and Objects 46

    3.5 Style Sheets and DHTML 48

        3.5.1 CSS: The Web’s Standard Language 48

        3.5.2 The Specific Syntax of CSS Declarations 50

        3.5.3 Selectors 50

4 How jQuery Works 51

    4.1 Accessing Elements of the Web Page 52

    4.2 The jQuery Namespace and the jQuery Object 54

    4.3 Special Data Types and Structures in jQuery 55

        4.3.1 Options 55

        4.3.2 Map 56

        4.3.3 The Array<Type> Notation 56

        4.3.4 jqXHR 57

    4.4 The Function jQuery() and the Alias $() 57

        4.4.1 The Context 59

    4.5 Executing Functions After DOM Has Been Built 60

        4.5.1 Callback or Anonymous Function as a Parameter of jQuery() 60

        4.5.2 Placing document.ready() into an External JavaScript File 63

        4.5.3 Example of Creating a Basic Structure for a Modularized jQuery Web Application 63

    4.6 Creating an Element with jQuery() and Inserting It into the Web Page 66

        4.6.1 Options for Initializing Attributes 68

    4.7 Wrapping Existing Elements with jQuery() 70

        4.7.1 Direct Access to DOM elements via get( ) 71

    4.8 Using jQuery in Combination with Other Frameworks 72

        4.8.1 The Function noConflict() 73

    4.9 More About Context 74

        4.9.1 context, selector, and nodeName 75

    4.10 Chaining jQuery Objects 77

        4.10.1 Executing Function Calls Sequentially: The jQuery Queue 78

    4.11 New Core Techniques Since Version 1.5 78

        4.11.1 jQuery.sub() 78

        4.11.2 jQuery.when() 79

        4.11.3 Version 1.6: What’s New? 79

        attr(), prop(), and removeProp() 80

        data() 81

5 Selectors and Filters 83

    5.1 The Basics 84

        5.1.1 What Is a Selector? 84

        5.1.2 What Are Filters? 84

        5.1.3 XPath as Basis 85

    5.2 The Basic Selectors and the Hierarchical Selectors 86

        5.2.1 Examples 88

        5.2.2 Potential Pitfalls 97

    5.3 Filtering Selectors 99

        5.3.1 Basic Filters 99

        5.3.2 Content Filters 106

        5.3.3 Visibility Filters 109

        5.3.4 Child Filters 112

        5.3.5 Attribute Filters 114

        5.3.6 Filters for Form Elements and Form Filters 118

    5.4 Filter Methods 123

        5.4.1 eq() 123

        5.4.2 not() 123

        5.4.3 first() and last() 124

        5.4.4 slice() 124

        5.4.5 filter() 125

        5.4.6 is() 126

        5.4.7 map() 127

6 Accessing the Elements of a Web Page 131

    6.1 General Info on Checking, Changing, Adding, and Removing Nodes 131

    6.2 Checking and Changing Node Contents: html() and text() 132

    6.3 Content of Form Fields: val() 135

    6.4 Accessing Attributes via attr() 137

    6.5 Inserting Nodes into a Web Page 137

        6.5.1 append() and prepend() 138

        6.5.2 appendTo() and prependTo() 143

    6.6 Inserting Nodes Before or After 148

        6.6.1 after() and before() 149

        6.6.2 insertAfter() and insertBefore() 152

    6.7 Wrapping 154

        6.7.1 Wrapping Individually with wrap() 154

        6.7.2 Wrapping All with wrapAll() 156

        6.7.3 Wrapping Inner Areas with wrapInner() 158

        6.7.4 Unwrapping with unwrap() 159

    6.8 Replacing with replaceWith() and replaceAll() 159

        6.8.1 Replacing with replaceWith() 160

        6.8.2 Replacing All with replaceAll() 164

        6.9 Removing with empty() and remove()/detach() plus removeAttr() 166

        6.9.1 The Alternative of remove(): detach() 171

        6.9.2 Deleting Attributes 171

    6.10 Cloning with clone() 172

    6.11 Search and Find 176

        6.11.1 Of Children and Parents: children() and parent() plus parents()/parentsUntil() 176

        6.11.2 offsetParent() and closest() 180

        6.11.3 Siblings 182

        6.11.4 Searching Descendants with has() 184

    6.12 Finding with find() and contents() 184

    6.13 The jQuery Method each() for Iterating over Arrays and Objects 186

        6.13.1 jQuery.each() 188

        6.13.2 The Method each() 192

    6.14 The add() Method 193

        6.14.1 The end() and andSelf() Methods 195

    6.15 A More Comprehensive Example at the End: A Date Component 196

7 Formatting with Style Sheets Under jQuery 205

    7.1 The css() Method 206

        7.1.1 Getting Style Properties 206

        7.1.2 Setting Properties 207

    7.2 Changing Classes of Elements 209

        7.2.1 Adding Classes: addClass() 210

        7.2.2 Removing Classes: removeClass() 218

        7.2.3 Toggling Classes with toggleClass() 219

        7.2.4 Testing for a Class: hasClass() 221

    7.3 Positioning Methods 223

        7.3.1 Determining the Position with position() 224

        7.3.2 Position in Relation to the Document: offset() 228

    7.4 Scrolling Methods 236

    7.5 Height and Width 239

        7.5.1 height() and width() 239

    7.6 Inner and Outer Dimensions 242

8 Event Handling Under jQuery 247

    8.1 Basic Information on Events, Event Handlers, Triggers, and Data Binding 247

        8.1.1 Events 247

        8.1.2 General Information on Event Handlers 248

        8.1.3 HTML Event Handlers 248

        8.1.4 JavaScript Event Handler 249

        8.1.5 The Event Object 250

        8.1.6 Bubbling 251

        8.1.7 Data Binding 251

        8.1.8 Trigger 252

    8.2 The Event Object in jQuery 252

        8.2.1 The Constructor of jQuery.Event 252

        8.2.2 The Properties of the Event Object jQuery.Event 253

        8.2.3 The Methods of an Object of the Type jQuery.Event 256

    8.3 Ready, Steady, Go: $(document).ready() 258

    8.4 Event Helpers 258

    8.5 Expanded Methods for Event Handling 262

        8.5.1 The bind() and unbind() Methods 262

        8.5.2 The One and Only: one() 266

        8.5.3 The Method trigger() 267

        8.5.4 triggerHandler() 269

        8.5.5 Live Events: The live() and die() Methods plus

        delegate() and undelegate() 270

        8.5.6 Auxiliary Functions for Interaction 274

9 Effects and Animations 279

    9.1 Basic Use 279

        9.1.1 Speed Is All You Need 279

        9.1.2 Specifying a Callback 280

        9.1.3 Chaining 281

        9.1.4 Queues 281

        9.1.5 Stopping via stop() and jQuery.fx.off 282

    9.1.6 Endless Animations 282

    9.1.7 Types of Animation 282

    9.2 Showing and Hiding: The show() and hide() Methods 283

    9.3 Sliding Effects: slideDown(), slideUp(), and slideToggle() 284

    9.4 Opacity Effects: fadeIn(), fadeOut(), and fadeTo() (Plus toggle()) 287

    9.5 Individual Animations with animate() 289

10 AJAX 297

    10.1 AJAX and XMLHttpRequest (XHR) Basics 297

        10.1.1 Creating an XMLHttpRequest Object Manually 298

        10.1.2 The Methods of an XHR Object 299

        10.1.3 The Properties of an XHR Object 300

        10.1.4 A Practical Example of Data Request Without Special jQuery Methods 300

        10.1.5 The Data Format in an AJAX Communication 302

        10.1.6 AJAX Request Process 303

    10.2 Special AJAX Support in jQuery 304

        10.2.1 JSONP and Remote Requests 304

        10.2.2 The jqXHR Object 305

        10.2.3 Methods in jQuery for AJAX Requests 305

        10.2.4 Specifying the Data Type 305

        10.2.5 Avoiding Caching 307

    10.3 $.get() and $.post() 307

        10.3.1 Just Requesting Plain Text from the Web Server 307

        10.3.2 Sending Data to the Web Server via $.get() and $.post() 309

        10.3.3 Getting and Parsing XML Data 312

    10.4 Getting and Parsing JSON Data: getJSON() and parseJSON() 316

        10.4.1 A Simple Application with JSON 316

        10.4.2 Requesting Twitter Tweets via JSONP 317

    10.5 Loading a Script Later via AJAX:

        jQuery.getScript() 320

    10.6 The General Variation for Loading Data: load() 322

        10.6.1 Specifying Filters 323

    10.7 Serializing Data 327

        10.7.1 The serialize() Method 327

        10.7.2 The serializeArray() Method 329

        10.7.3 The General Version: param() 329

    10.8 Default Values for AJAX 330

    10.9 AJAX Events and AJAX Event Handlers 330

        10.9.1 Local Events 330

        10.9.2 Global Events 332

    10.10 Complete Control 333

        10.10.1 jQuery.ajax() 333

        10.10.2 A JSONP Request 339

        10.10.3 Loading and Executing a JavaScript File 340

        10.10.4 Sending Data Plus Evaluating the Success 340

        10.10.5 Extended Techniques for $.ajax() 341

11 jQuery UI 345

    11.1 What Is jQuery UI? 345

        11.1.1 Components for Supporting Interaction 346

        11.1.2 Widgets 346

        11.1.3 Extended Effects 347

        11.1.4 The Theme Framework and ThemeRoller 347

    11.2 Getting Started 348

    11.3 How Is jQuery UI Used? 349

        11.3.1 Downloading and ThemeRoller 349

        11.3.2 Using jQuery UI on a Web Page 353

        11.3.3 A Sample Web Page for jQuery UI 355

    11.4 Using the Components in jQuery UI 355

        11.4.1 The Default Setting 356

        11.4.2 Some Basic Rules on Components and Widgets 358

        11.4.3 Properties/Options of Components 359

        11.4.4 Methods of Components 363

        11.4.5 Events in Components and Widgets 366

    11.5 An Overview of the Components and Widgets 370

        11.5.1 The Interaction Components 370

        11.5.2 The Widgets 372

        11.5.3 Utilities 385

    11.6 Effects 385

        11.6.1 The effect() Method 385

        11.6.2 Color Animations with animate() 386

    11.7 A Complete Website Based on jQuery UI 387

12 Plug-Ins 393

    12.1 The jQuery Plug-In Page 393

        12.1.1 Searching For and Using an Existing Plug-In 394

        12.1.2 Validation Plug-Ins 397

    12.2 Creating Custom Plug-Ins 405

        12.2.1 Why Create Custom Plug-Ins? 405

        12.2.2 Creating Your First Plug-In 405

        12.2.3 The Main Rules for Creating a Simple Plug-In 409

        12.2.4 Rules for Creating More Complex Plug-Ins 409

        12.2.5 An Example for a Plug-In with Options 411

        12.2.6 Another Example for a Plug-In with Options 413

    12.3 Publishing a Plug-In 415

13 jQuery Mobile 417

    13.1 Basics 417

        13.1.1 The Platforms 419

        13.1.2 Downloading and Integrating the Framework 420

        13.1.3 Alternatives 421

    13.2 The Role System and data-role 422

    13.3 The Basic Structure of a Mobile Web Page 422

    13.4 Linking Pages 424

        13.4.1 External Links via Hijax 424

        13.4.2 Internal Links and the Special Interpretation of a Page 425

    13.5 The Transitions 428

    13.6 Dialogs 428

    13.7 Buttons 429

        13.7.1 Buttons with Icons 430

        13.7.2 Block Element or Inline Element 431

        13.7.3 Grouping 431

        13.7.4 A Practical Example 432

    13.8 Toolbars and Navigation Bars 435

    13.9 Lists 439

    13.10 Form Elements 443

        13.10.1 Field Containers 444

        13.10.2 The Various Form Elements 444

        13.10.3 Plug-In Methods for Form Elements 447

        13.10.4 Sending the Form Data 448

    13.11 Special Events 448

        13.11.1 Touch Events 448

        13.11.2 Orientation Change 448

        13.11.3 Scroll Events 449

        13.11.4 Page Events 449

    13.12 The Theme Framework and General Content Design 452

    13.13 Collapsed and Expanded Content 454

Appendix 457

TOC, 9780321815262, 4/10/2013

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020