MEAP Edition
Manning Early Access Programcefview是什么程序
Copyright 2007 Manning Publications
For more information on this and other Manning titles go to
www.manning
Contents
Chapter 1 - Introducing jQuery
函数offset的功能是Chapter 2 - Creating the wrapped element set
Chapter 3 - Bringing pages to life with jQuery
Chapter 4 - Events are where it happens
Chapter 5 - Animations and Effects
Chapter 6 - jQuery utility functions and flags
Chapter 7 - Creating your own plugins
Chapter 8 - Talk to your server with Ajax
Chapter 9 - The Core UI Plugin
Chapter 10 - Official Plugins
Appendix A - JavaScript that you need to know but might not!
Appendix B - Alphabetical API Reference
jquery下载超大文件Chapter 1
Introducing jQuery
zorin系统This chapter covers
Why you should use jQuery
What “Unobtrusive JavaScript” meanstp5漏洞利用
The fundamental elements and concepts of jQuery
Using jQuery in conjunction with other JavaScript libraries
Considered a “toy” language by serious web developers for most of its lifetime, JavaScript has regain
ed its prestige in the past few years as a result of the renewed interest in Rich Internet Applications and Ajax technologies. As a result, the language has had to grow up quickly, with client-side developers tossing aside cut-and-paste JavaScript for the convenience of full-featured JavaScript libraries that solve difficult cross-browser problems once and for all and which have provided new and improved paradigms for web development.
A relative latecomer to this world of JavaScript libraries, jQuery has taken the web development community by storm, quickly winning the support of major websites like MSNBC and well-regarded open-source projects, including SourceForge, Trac, and Drupal.
Compared with other toolkits that focus heavily on clever JavaScript techniques, jQuery aims to change the way that web developers fundamentally think about creating rich functionality in their pages. Rather than spending a lot of time juggling the complexities of object-oriented JavaScript, designers can leverage their existing knowledge of CSS, XHTML and straight-forward JavaScript to manipulate page elements directly, making more rapid development a reality.
Let’s find out what exactly jQuery brings to the page development party.
1.1 Why jQuery?
If you’ve spent any time at all trying to layer dynamic functionality onto your pages, you’ll find that you are constantly following a common pattern of selecting an element or group of elements, and operating upon those elements in some fashion. You could be hiding or revealing the elements, or adding a CSS class to them, or animating them, or simply modifying their attributes.
Using raw JavaScript, each of those tasks can require dozens of lines of JavaScript code. The creators of jQuery, on the other hand, specifically created the library to make these common types of tasks trivial. For example, designers will commonly use JavaScript to “zebra-stripe” tables, highlighting every other row in a table with a contrasting color.
Using native JavaScript, that can take up to ten lines of code or more. Here’s how you accomplish it using jQuery:
$("table tr:nth-child(even)").addClass("striped");
Don’t worry if that looks a bit cryptic to you right now. In very short order, you’ll be understanding how it works and whipping out your own terse, but powerful, jQuery statements to make your pages come alive. But first, let’s briefly examine how this code snippet works.
Simply stated, we identify every even row (<tr> element) in all of the tables on the page and add the CSS class striped to each of those rows. By applying the desired background color to these rows via a CSS rule for class striped, a single line of JavaScript can improve the aesthetics of the entire page.
When applied to a sample table, the effect could be as shown in figure 1.1.
Figure 1.1: Adding “zebra stripes” to a table in just one statement!
Of course, the real power in this jQuery statement comes from the selector, which allowed us to easily identify and “grab” just the elements that we needed; in this case, every even <tr> element in all tables. You will find the full source for this page in the downloadable source code for this book in file chapter1/zebra.stripes.html.
We’ll be studying how to create these selectors with ease, but first let’s talk a little about how the inventors of jQuery view how JavaScript can be most effectively used in your pages.
springboot 面试题1.2 Unobtrusive JavaScript
Remember the bad old days before CSS (Cascading Style Sheets), when we were forced to mix stylistic markup with the document structure markup in our HTML pages?
I’m sure that we all do, and with perhaps a little shudder. The addition of CSS to our web development toolkits allowed us to separate stylistic information from the document structure and give travesties like the <font> tag the well-deserved boot. Not only does the separation of style from structure make our documents easier to manage, it also gives us the versatility to completely change the stylistic rendering of a page by simply swapping out different stylesheets.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论