jQuery参考手册(影印版)
基本信息
- 作者: Cody Lindley
- 丛书名: 南京东南大学出版社O'Reilly系列
- 出版社:东南大学出版社
- ISBN:9787564124151
- 上架时间:2010-11-23
- 出版日期:2010 年10月
- 开本:16开
- 页码:451
- 版次:1-1
- 所属分类:
计算机 > 软件与程序设计 > 网络编程 > javascript
推荐阅读
内容简介回到顶部↑
jquery简化了丰富的、交互web前端的构建过程。学会上手这个javascript库不难,但是若要全面掌握、深入理解,恐怕得花费多年时间。本书合理地缩短了学习曲线。在各个章节中,你将从很多领先的开发者那里学习模式和实践,他们到处使用,iquery,从将简单组件整合进网站到开发复杂的高性能用户界面。
作为javascript新手和行家的理想选择,《jquery cookbook》从基础知识开始,然后转向实际用例,包括经验证的解决方案和常见的web开发障碍。你还能看到高级议题相关章节,如将iquery应用到大型项目中去的方法等。
·解决包括事件、效果、维度、表单、主题以及用户界面元素等在内的各种问题
·学习如何优化表单,以及如何在页面上定位和重定位元素
·最大化运用jquery的事件管理系统,包括定制事件和定制事件数据
·创建ui元素——包括标签、折叠、模态——从头做起
·优化代码以减少瓶颈并保证高峰性能
·学习如何测试jquery应用
·应用jquery ui css框架和主题
作为javascript新手和行家的理想选择,《jquery cookbook》从基础知识开始,然后转向实际用例,包括经验证的解决方案和常见的web开发障碍。你还能看到高级议题相关章节,如将iquery应用到大型项目中去的方法等。
·解决包括事件、效果、维度、表单、主题以及用户界面元素等在内的各种问题
·学习如何优化表单,以及如何在页面上定位和重定位元素
·最大化运用jquery的事件管理系统,包括定制事件和定制事件数据
·创建ui元素——包括标签、折叠、模态——从头做起
·优化代码以减少瓶颈并保证高峰性能
·学习如何测试jquery应用
·应用jquery ui css框架和主题
目录回到顶部↑
foreword
contributors
preface
1. jquery basks
1.1 including the jquery library code in an html page
1.2 executing jquery/javascript coded after the dom has loaded but before complete page load
1.3 selecting dom elements using selectors and the jquery function
1.4 selecting dom elements within a specified context
1.5 filtering a wrapper set of dom elements
1.6 finding descendant elements within the currently selected wrapper set
1.7 returning to the prior selection before a destructive change
1.8 including the previous selection with the current selection
1.9 traversing the dom based on your current context to acquire a new set of dom elements
1.10 creating, operating on, and inserting dom elements
1.11 removing dom elements
1.12 replacing dom elements
1.13 cloning dom elements
1.14 getting, setting, and removing dom element attributes
1.15 getting and setting html content
1.16 getting and setting text content
contributors
preface
1. jquery basks
1.1 including the jquery library code in an html page
1.2 executing jquery/javascript coded after the dom has loaded but before complete page load
1.3 selecting dom elements using selectors and the jquery function
1.4 selecting dom elements within a specified context
1.5 filtering a wrapper set of dom elements
1.6 finding descendant elements within the currently selected wrapper set
1.7 returning to the prior selection before a destructive change
1.8 including the previous selection with the current selection
1.9 traversing the dom based on your current context to acquire a new set of dom elements
1.10 creating, operating on, and inserting dom elements
1.11 removing dom elements
1.12 replacing dom elements
1.13 cloning dom elements
1.14 getting, setting, and removing dom element attributes
1.15 getting and setting html content
1.16 getting and setting text content
前言回到顶部↑
The jQuery library has taken the frontend development world by storm. Its dead-simple syntax makes once-complicated tasks downright trivial--enjoyable, even. Many a developer has been quickly seduced by its elegance and clarity. If you've started using the library, you're already adding rich, interactive experiences to your projects.
Getting started is easy, but as is the case with many of the tools we use to develop websites, it can take months or even years to fully appreciate the breadth and depth of the jQuery library. The library is chock-full of features you might never have known to wish for. Once you know about them, they can dramatically change how you approach the problems you're called upon to solve.
The goal of this cookbook is to expose you, dear reader, to the patterns and practices of some of the leading frontend developers who use jQuery in their everyday projects.Over the course of 18 chapters, they'll guide you through solutions to problems that range from straightforward to complex. Whether you're a jQuery newcomer or a grizzled JavaScript veteran, you're likely to gain new insight into harnessing the full power ofjQuery to create compelling, robust, high-performance user interfaces.
Who This Book Is For
Maybe you're a designer who is intrigued by the interactivity that jQuery can provide.Maybe you're a frontend developer who has worked with jQuery before and wants to see how other people accomplish common tasks. Maybe you're a server-side developer who's frequently called upon to write client-side code.
Truth be told, this cookbook will be valuable to anyone who works with jQuery-or who hopes to work with jQuery. If you're just starting out with the library, you may want to consider pairing this book with Learning jQuery 1.3 from Packt, or jQuery in Action from Manning. If you're already using jQuery in your projects, this book will serve to enhance your knowledge of the library's features, hidden gems, and idiosyncrasies.
What You'll Learn
We'll start out by covering the basics and general best practices--including jQuery in your page, making selections, and traversing and manipulation. Even frequent jQuery users are likely to pick up a tip or two. From there, we move on to real-world use cases,walking you through tried-and-true (and tested) solutions to frequent problems involving events, effects, dimensions, forms, and user interface elements (with and without the help of jQuery UI). At the end, we'll take a look at testing your jQuery applications and integrating jQuery into complex sites.
Along the way, you'll learn strategies for leveraging jQuery to solve problems that go far beyond the basics. We'll explore how to make the most of jQuery's event management system, including custom events and custom event data; how to progressively enhance forms; how to position and reposition elements on the page; how to create user interface elements such as tabs, accordions, and modals from scratch; how to craft your code for readability and maintainability; how to optimize your code to ease testing,eliminate bottlenecks, and ensure peak performance; and more.
Because this is a cookbook and not a manual, you're of course welcome to cherry-pick the recipes you read; the individual recipes alone are worth the price of admission. As a whole, though, the book provides a rare glimpse into the problem-solving approaches of some of the best and brightest in the jQuery community. With that in mind, we encourage you to at least skim it from front to back--you never know which line of code will provide the "Aha!" moment you need to take your skills to the next level.
jQuery Style and Conventions
jQuery places a heavy emphasis on chaining--calling methods on element selections in sequence, confident in the knowledge that each method will give you back a selection of elements you can continue to work with. This pattern is explained in depth in Chapter 1--if you're new to the library, you'll want to understand this concept, because it is used heavily in subsequent chapters.
jQuery's features are organized into a handful of simple categories: core functionality, selecting, manipulating, traversing, CSS, attributes, events, effects, Ajax, and utilities.Learning these categories, and how methods fit into them, will greatly enhance your understanding of the material in this book.
One of the best practices this book will cover is the concept of storing element selections in a variable, rather than making the same selection repeatedly. When a selection is stored in a variable, it is commonplace for that variable to begin with the $ character, indicating that it is a jQuery object. This can make code easier to read and maintain, but it should be understood that starting the variable name with the $ character is merely a convention; it carries no special meaning, unlike in other languages such as PHP.
In general, the code examples in this book strive for clarity and readability over compactness, so the examples may be more verbose than is strictly necessary. Ifyou see an opportunity for optimization, you should not hesitate to take it. At the same time, you'll do well to strive for clarity and readability in your own code and use minification tools to prepare your code for production use.
Other Options
If you're looking for other jQuery resources, here are some we recommend:
~ Learning jQuery 1.3, by Jonathan Chaffer, Karl Swedberg, and John Resig (Packt)
~ jQuery in Action, by Bear Bibeault, Yehuda Katz, and John Resig (Manning)
~ jQuery UI 1.6: The User Interface Libraryfor jQuery, by Dan Wellman (Packt)
Getting started is easy, but as is the case with many of the tools we use to develop websites, it can take months or even years to fully appreciate the breadth and depth of the jQuery library. The library is chock-full of features you might never have known to wish for. Once you know about them, they can dramatically change how you approach the problems you're called upon to solve.
The goal of this cookbook is to expose you, dear reader, to the patterns and practices of some of the leading frontend developers who use jQuery in their everyday projects.Over the course of 18 chapters, they'll guide you through solutions to problems that range from straightforward to complex. Whether you're a jQuery newcomer or a grizzled JavaScript veteran, you're likely to gain new insight into harnessing the full power ofjQuery to create compelling, robust, high-performance user interfaces.
Who This Book Is For
Maybe you're a designer who is intrigued by the interactivity that jQuery can provide.Maybe you're a frontend developer who has worked with jQuery before and wants to see how other people accomplish common tasks. Maybe you're a server-side developer who's frequently called upon to write client-side code.
Truth be told, this cookbook will be valuable to anyone who works with jQuery-or who hopes to work with jQuery. If you're just starting out with the library, you may want to consider pairing this book with Learning jQuery 1.3 from Packt, or jQuery in Action from Manning. If you're already using jQuery in your projects, this book will serve to enhance your knowledge of the library's features, hidden gems, and idiosyncrasies.
What You'll Learn
We'll start out by covering the basics and general best practices--including jQuery in your page, making selections, and traversing and manipulation. Even frequent jQuery users are likely to pick up a tip or two. From there, we move on to real-world use cases,walking you through tried-and-true (and tested) solutions to frequent problems involving events, effects, dimensions, forms, and user interface elements (with and without the help of jQuery UI). At the end, we'll take a look at testing your jQuery applications and integrating jQuery into complex sites.
Along the way, you'll learn strategies for leveraging jQuery to solve problems that go far beyond the basics. We'll explore how to make the most of jQuery's event management system, including custom events and custom event data; how to progressively enhance forms; how to position and reposition elements on the page; how to create user interface elements such as tabs, accordions, and modals from scratch; how to craft your code for readability and maintainability; how to optimize your code to ease testing,eliminate bottlenecks, and ensure peak performance; and more.
Because this is a cookbook and not a manual, you're of course welcome to cherry-pick the recipes you read; the individual recipes alone are worth the price of admission. As a whole, though, the book provides a rare glimpse into the problem-solving approaches of some of the best and brightest in the jQuery community. With that in mind, we encourage you to at least skim it from front to back--you never know which line of code will provide the "Aha!" moment you need to take your skills to the next level.
jQuery Style and Conventions
jQuery places a heavy emphasis on chaining--calling methods on element selections in sequence, confident in the knowledge that each method will give you back a selection of elements you can continue to work with. This pattern is explained in depth in Chapter 1--if you're new to the library, you'll want to understand this concept, because it is used heavily in subsequent chapters.
jQuery's features are organized into a handful of simple categories: core functionality, selecting, manipulating, traversing, CSS, attributes, events, effects, Ajax, and utilities.Learning these categories, and how methods fit into them, will greatly enhance your understanding of the material in this book.
One of the best practices this book will cover is the concept of storing element selections in a variable, rather than making the same selection repeatedly. When a selection is stored in a variable, it is commonplace for that variable to begin with the $ character, indicating that it is a jQuery object. This can make code easier to read and maintain, but it should be understood that starting the variable name with the $ character is merely a convention; it carries no special meaning, unlike in other languages such as PHP.
In general, the code examples in this book strive for clarity and readability over compactness, so the examples may be more verbose than is strictly necessary. Ifyou see an opportunity for optimization, you should not hesitate to take it. At the same time, you'll do well to strive for clarity and readability in your own code and use minification tools to prepare your code for production use.
Other Options
If you're looking for other jQuery resources, here are some we recommend:
~ Learning jQuery 1.3, by Jonathan Chaffer, Karl Swedberg, and John Resig (Packt)
~ jQuery in Action, by Bear Bibeault, Yehuda Katz, and John Resig (Manning)
~ jQuery UI 1.6: The User Interface Libraryfor jQuery, by Dan Wellman (Packt)
序言回到顶部↑
When I first started work on building jQuery, back in 2005, I had a simple goal in mind: I wanted to be able to write a web application and have it work in all the major browsers--without further tinkering and bug fixing. It was a couple of months before I had a set of utilities that were stable enough to achieve that goal for my personal use.I thought I was relatively done at this point; little did I know that my work was just beginning.
Since those simple beginnings, jQuery has grown and adapted as new users use the library for their projects. This has proven to be the most challenging part of developing a JavaScript library; while it is quite easy to build a library that'll work for yourself or a specific application, it becomes incredibly challenging to develop a library that'll work in as many environments as possible (old browsers, legacy web pages, and strange markup abound). Surprisingly, even as jQuery has adapted to handle more use cases,most of the original APl has stayed intact.
One thing I find particularly interesting is to see how developers use j Query and make it their own. As someone with a background in computer science, I find it quite surprising that so many designers and nonprogrammers find jQuery to be compelling.Seeing how they interact with the library has given me a better appreciation of simple APl design. Additionally, seeing many advanced programmers take jQuery and develop large, complex applications with it has been quite illuminating. The best part of all of this, though, is the ability to learn from everyone who uses the library.
A side benefit of using jQuery is its extensible plugin structure. When I first developed jQuery, I was sure to include some simple ways for developers to extend the APl that it provided. This has blossomed into a large and varied community of plugins, encompassing a whole ecosystem of applications, developers, and use cases. Much of jQuery's growth has been fueled by this community--without it, the library wouldn't be where it is today, so I'm glad that there are chapters dedicated to some of the most interesting plugins and what you can do with them. One of the best ways to expand your preconceived notion of what you can do with jQuery is to learn and use code from the jQuery plugin community.
This is largely what makes something like a cookbook so interesting: it takes the cool things that developers have done, and have learned, in their day-to-day coding and distills it to bite-sized chunks for later consumption. Personally, I find a cookbook to be one of the best ways to challenge my preconceived notions of a language or library.I love seeing cases where an API that I thought I knew well is turned around and used in new and interesting ways. I hope this book is able to serve you well, teaching you new and interesting ways to use jQuery.
--John Resig
Creator, Lead Developer, jQuery
Since those simple beginnings, jQuery has grown and adapted as new users use the library for their projects. This has proven to be the most challenging part of developing a JavaScript library; while it is quite easy to build a library that'll work for yourself or a specific application, it becomes incredibly challenging to develop a library that'll work in as many environments as possible (old browsers, legacy web pages, and strange markup abound). Surprisingly, even as jQuery has adapted to handle more use cases,most of the original APl has stayed intact.
One thing I find particularly interesting is to see how developers use j Query and make it their own. As someone with a background in computer science, I find it quite surprising that so many designers and nonprogrammers find jQuery to be compelling.Seeing how they interact with the library has given me a better appreciation of simple APl design. Additionally, seeing many advanced programmers take jQuery and develop large, complex applications with it has been quite illuminating. The best part of all of this, though, is the ability to learn from everyone who uses the library.
A side benefit of using jQuery is its extensible plugin structure. When I first developed jQuery, I was sure to include some simple ways for developers to extend the APl that it provided. This has blossomed into a large and varied community of plugins, encompassing a whole ecosystem of applications, developers, and use cases. Much of jQuery's growth has been fueled by this community--without it, the library wouldn't be where it is today, so I'm glad that there are chapters dedicated to some of the most interesting plugins and what you can do with them. One of the best ways to expand your preconceived notion of what you can do with jQuery is to learn and use code from the jQuery plugin community.
This is largely what makes something like a cookbook so interesting: it takes the cool things that developers have done, and have learned, in their day-to-day coding and distills it to bite-sized chunks for later consumption. Personally, I find a cookbook to be one of the best ways to challenge my preconceived notions of a language or library.I love seeing cases where an API that I thought I knew well is turned around and used in new and interesting ways. I hope this book is able to serve you well, teaching you new and interesting ways to use jQuery.
--John Resig
Creator, Lead Developer, jQuery
媒体评论回到顶部↑
“我喜欢看到一个此前熟知的API,转而通过另外一种又新奇又有趣的方式得以运用。我希望此书对你有用,教会你以新奇而有趣的方式来使用jQuery。”
——John Resig
jQuery库创建者
——John Resig
jQuery库创建者

点击看大图


加载中...
