A good code style can effectively increase readability. This section describes the code style of the jQuery program. If you are interested, refer to Chapter 1st of the jQuery authoritative guide to get started with jQuery development, this chapter introduces the download of the jQuery library and introduces simple application methods based on the basic concepts of jQuery; the latter part focuses on jQuery's introduction to DOM object control and page CSS styles. through some simple small examples, readers can have a general understanding of jQuery's functional applications on pages, this lays the foundation for the next chapter to learn more about the detailed objects and methods of the jQuery library. This section describes the code style of the jQuery program.
1.1.5 code style of the jQuery Program
1. Use of the $ Operator
In the jQuery program, the most commonly used is the $ symbol. This symbol must be used for selection of page elements and prefix of function functions, it can be said that it is a sign of the jQuery program.
2. Event operation link writing
When writing an element event on a page, the jQuery program can write all the events of the element in a link-based manner. In order to better illustrate the use of this writing method, we will elaborate through an example.
Example 1-2 jQuery event chain writing
(1) Function Description
On the page, there is
Tag, which contains two
Tag. One is the topic and the other is the content. The content contained when the page is loaded for the first time.
The tag is invisible. When the user clicks the topic
Changes the background color and
Marked.
(2) Implementation Code
Create an HTML file 1-2.html and add the code shown in code 1-2.
Code List 1-2 chained Writing of jQuery events
The Code is as follows:
Transitional // EN"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
JQuery event chain writing