jquery外文翻译

2018-12-22 19:01

外文原文

The Introduction Of jQuery

What jQuery does

The jQuery library provides a general-purpose abstraction layer for common web scripting, and is therefore useful in almost every scripting situation. Its extensible nature means that we could never cover all possible uses and functions in a single book, as plugins are constantly being developed to add new abilities. The core features, though, address the following needs: ?

Access elements in a document. Without a JavaScript library, many lines of code must be written to traverse the Document Object Model (DOM) tree, and locate specific portions of an HTML document's structure. A robust and efficient selector mechanism is offered in jQuery for retrieving the exact piece of the document that is to be inspected or manipulated. ?

Modify the appearance of a web page. CSS offers a powerful method of influencing the way a document is rendered, but it falls short when web browsers do not all support the same standards. With jQuery, developers can bridge this gap, relying on the same standards support across all browsers. In addition, jQuery can change the classes or individual style properties applied to a portion of the document even after the page has been rendered. ?

Alter the content of a document. Not limited to mere cosmetic changes, jQuery can modify the content of a document itself with a few keystrokes. Text can be changed, images can be inserted or swapped, lists can be reordered, or the entire structure of the HTML can be rewritten and extended—all with a single easy-to-use Application Programming Interface (API). ?

Respond to a user's interaction. Even the most elaborate and powerful behaviors are not useful if we can't control when they take place. The jQuery library offers an elegant way to intercept a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers. At the same time, its event-handling API removes browser inconsistencies that often plague web developers. ?

Retrieve information from a server without refreshing a page. This code pattern has become known as Asynchronous JavaScript And XML (AJAX), and assists web developers in crafting a responsive, feature-rich site. ?

Simplify common JavaScript tasks. In addition to all of the document-specific features of jQuery, the library provides enhancements to basic JavaScript constructs such as iteration and array manipulation.

Why jQuery works well

With the recent resurgence of interest in dynamic HTML comes a proliferation of JavaScript

Jonathan Chaffer & Karl Swedberg ; Learning jQuery ; February 2009 , p7-10

外文原文

frameworks. Some are specialized, focusing on just one or two of the above tasks. Others attempt to catalog every possible behavior and animation, and serve these all up pre-packaged. To maintain the wide range of features outlined above while remaining compact, jQuery employs several strategies: ?

Leverage knowledge of CSS. By basing the mechanism for locating page elements on CSS selectors, jQuery inherits a terse yet legible way of expressing a document's structure. The jQuery library becomes an entry point for designers who want to add behaviors to their pages because a prerequisite for doing professional web development is knowledge of CSS syntax. ?

Support extensions. In order to avoid \creep\jQuery relegates special-case uses to plugins. The method for creating new plugins is simple and well-documented, which has spurred the development of a wide variety of inventive and useful modules. Even most of the features in the basic jQuery download are internally realized through the plugin architecture, and can be removed if desired, yielding an even smaller library. ?

Abstract away browser quirks. An unfortunate reality of web development is that each browser has its own set of deviations from published standards. A significant portion of any web application can be relegated to handling features differently on each platform. While the ever-evolving browser landscape makes a perfectly browser-neutral code base impossible for some advanced features, jQuery adds an abstraction layer that normalizes the common tasks, reducing the size of code, and tremendously simplifying it. ?

Always work with sets. When we instruct jQuery, Find all elements with the class collapsible and hide them, there is no need to loop through each returned element. Instead, methods such as .hide() are designed to automatically work on sets of objects instead of individual ones. This technique, called implicit iteration, means that many looping constructs become unnecessary, shortening code considerably. ?

Allow multiple actions in one line. To avoid overuse of temporary variables or wasteful repetition, jQuery employs a programming pattern called chaining for the majority of its methods. This means that the result of most operations on an object is the object itself, ready for the next action to be applied to it.

These strategies have kept the jQuery package slim—under 20 KB compressed—while at the same time providing techniques for keeping our custom code that uses the library compact, as well.

Jonathan Chaffer & Karl Swedberg ; Learning jQuery ; February 2009 , p7-10

外文原文

jQquery的介绍

jQuery 能做什么

jQuery库为共同的web脚本提供通用的抽象层,它几乎适用于每一种脚本环境。它的可扩展性自然意味着我们不可能在一本书里涵盖所有可能的用途与功能,它以插件的形式持续地被加入新的功能。但核心的特性,都满足以下的需求: ?

访问页面文档的元素。不使用JavaScript库的话,必须写很多行代码来遍历DOM树,并设置HTML文档的指定部分。jQuery提供了一个强大有效的选择机制来检索被检查或被操作的文档的确切片段。 ?

修改页面的外观。CSS 提供了一个影响文档渲染的强有力的方法,但是当web浏览器不支持同样的标准时,它却不怎么理想。而jQuery能使开发者缩小这个差距,它依靠同一标准支持横跨所有浏览器。另外,当页面被渲染后,jQuery仍然能改变文档一部分的类或者独立的样式属性。 ?

修改页面文档的内容。不仅限于外观的改变,jQuery 还可以用很少的按键就可修改文档的内容本身。可以改变文本,可以插入或替换图像,可以重新排序列表,或者重写和扩展整个HTML结构,完成这些只需一套简单易用的 API 函数。 ?

响应用户的交互。当它们发生时,如果我们不能控制,即使是最周密最有力的行为也是没有用的。jQuery库提供了一个优雅的方法来截取各种事件,例如用户单击一个链接,不需要将事件句柄混杂到HTML代码本身之中。同时,事件句柄API去除浏览器不一致性往往会困扰web开发者。 ?

无刷新返回服务器端的信息。这个代码模式已经以Asynchronous JavaScript and XML(AJAX)著称了,并协助web开发者制作一个可响应的功能丰富的网站。 ?

简化共同的JavaScript任务,除了jQuery文档的所有特性外,这个库还提供了改进基本的JavaScript结构,如秩代和数组操作。

为什么jQuery工作地那么好

随着近期动态HTML兴趣的复兴,JavaScript框架快速增加。有些很专业,只侧重于一个或者两个以上的任务。其它的则试图编出每一种可能的行为与动画,而这些服务都被预先包装。为了保持其广泛的特性并且保持简洁,jQuery 使用了一些策略: ?

CSS的杠杆作用的知识。在CSS选择器定位页面元素的机制的基础上,jQuery继承了表现文档结构的简洁易读的方法。由于做专业的web开发的必备知识是CSS语法,jQuery库为想在他们的页面上添加行为的设计师提供了一个入口。 ?

支持扩展。为了避免“特征变化”,jQuery提供了特殊用途的插件。创建一个新插件的方法是简单的并且有明确记录的,这种方法已经带动了各种发明和有用的模块的发展。甚至在基

Jonathan Chaffer & Karl Swedberg ; Learning jQuery ; February 2009 , p7-10

外文原文

本的jQuery下载中的大部分特性都是通过插入式结构内部实现的,并且可以根据需要被删除,产生一个更小的库。 ?

去除浏览器的变化。web开发的一个不幸的事实是每个浏览器发布的标准有偏差。任何web应用程序的一个重要的部分可在每个平台上处理不同的特性。当不断变化的浏览器现状使一些高级特性不适用于一个完美的浏览器中立代码基地,jQuery添加了一个抽象层来规范这些共同的任务,减少代码的大小,并且尽量简化它。 ?

总是以集合工作。当我们指示jQuery查找所有带类可折叠的元素并隐藏它时,不需要循环每个返回的元素。相反,如.hide()的方法被设计工作在对象集上而不是单独元素。这种技术,被称为隐含叠代,意味着很多循环结构变得不必要了,可观地缩短了代码。 ?

允许在一行有多个动作。为了避免临时变量或浪费的重复的过度使用,jQuery在它的大多数方法中使用了一个称为链式的编程模式。这意味着大多数对象操作的结果都这个对象的本身,为下一个要应用它的动作做准备。

这些策略保持jQuery包很轻巧,压缩后只有20KB左右,同时,也提供了保持使用这个库的自定义代码的简单性的技术。

Jonathan Chaffer & Karl Swedberg ; Learning jQuery ; February 2009 , p7-10


jquery外文翻译.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:24届计算机表演赛命题搜索答案之数学图形类

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: