(2) Getting Started Guide -- (2) What jQuery can do (WhatjQuerydoes)
Source: Internet
Author: User
ThejQuerylibraryprovidesageneral-purpose?actionlayerforcommonwebscripting, andis, therefore, usefulinalmosteveryscriptingsituation. itsextensiblenatur... the jQuery library provides a general-purpose your action layer for common web scripting, and is, therefore, useful in almost every scripting situation. its extensible nature means that we coshould never cover all possible uses and functions in a sin Gle book, as plugins are constantly being developed to add new abilities. the core features, though, assist us in accomplishing the following tasks: The jQuery Library provides a multi-purpose Conceptual Hierarchy for general web scripts, therefore, it is useful in almost all script environments. His scalability is because it is impossible for us to cover all his possible usage methods and functions in a book, just as plug-ins are constantly developed to add new features. However, his core functions help us complete the following functions: Access elements in a document: Without a JavaScript library, web developers often need to write your lines of code to traverse the Document ObjectModel (DOM) tree and locate specific portions of an HTML document's structure. with jQuery, developers have a robust and efficient selector mechanic at their disposal, making it easy to retrieve the exact piece of the document that ne Eds to be inspected or manipulated. $ ('div. content '). find ('P'); Access document elements: If the js library is not used, web developers usually need to write a lot of lines of code to traverse the DOM tree and find a specific position in the element HTML structure. But with jQuery, they will have a powerful and efficient selector, which makes it easy to retrieve part of documents that need to be retrieved or operated. $ ("Div. content "). find ("p"); 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 using SS 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. $ ('ul> li: first '). addClass ('active'); Modify the display style of a page: css provides a powerful method that affects page rendering. However, it is uncomfortable that not all browsers support the same standard. With jquery, developers can use the standards supported by all browsers to overcome these gaps. In addition, jquery can change the classes and styles applied to some documents even after document rendering. $ ('Ul> li: first '). addClass ('active'); 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 ). $ ('# Iner '). append ('more'); Modify document content: it is not limited to simply beautifying page changes. You can modify the document content by typing jquery on the keyboard a few times. The text can be modified, images can be inserted or exchanged, the list can be reorganized, and all the document structures can be rewritten or expanded-all relying on a simple api. $ ('# Iner '). append ('more'); 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 remove S browser inconsistencies that often plague web developers. $ ('button. show-details '). click (function () {$ ('div. details '). show () ;}); responds to user interactions: even the most elaborate and powerful actions are useless if we don't control them when they happen. The jquery Library provides an elegant way to handle many types of events. For example, you can click a link without using event processing to confuse html code. At the same time, the event processing api also removes the compatibility issues that often plague web developers. $ ('Button. show-details '). click (function () {$ ('div. details '). show () ;}); Animate changes being made to a document: To define tively implement such interactive behaviors, a designer must also provide visual feedback to the user. the jQuery library facilitates this by providing an array of effects such as fades and wipes, as well as a toolkit for crafting new graphic displays. $ ('div. details '). slideDown (); Add animated changes to the document: to effectively implement interaction, the designer must also provide users with visual feedback. Jquery provides an array of effects, such as fade-out, clear, and a toolbox for elaborate image presentation. $ ('Div. details '). slideDown (); Retrieve information from a server without refreshing a page: This code pattern has become known as Ajax, which originally stood for asynchronousJavaScript and XML, but has since come to represent a much greater set of technologies for communicating between the client and the server. the jQuery library removes the browser-specific complexity from this responsive, featur Erich process, allowing developers to focus on the server-end functionality.(('div.details'0000.load('more.html # content'); refreshing data retrieval from the server: This code mode is well known as ajax, it represents Asynchronous javascript and XML, but it already represents a more powerful technology for communication between the client and the server. The jqery library removes the complexity of the browser from the very special process of the response, allowing developers to focus on the features of the server. Parameters # content'); 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. $. each (obj, function (key, value) {total + = value;}); simple js tasks: Except for all the clear jquery features of these documents, jquery provides enhancements to basic js concepts, such as iteration and array control. $. Each (obj, function (key, value) {total + = value ;}); downloading the example code You can download the example code files for all Packt books you have purchased from your account http://www.PacktPub.com . If you purchased this book elsewhere, you can visit http://www.PacktPub.com /Supportand register to have the files e-mailed directly to you.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service