JQuery Study Notes (1)

Source: Internet
Author: User
Today is my first day of learning jQuery. The main learning content is as follows: 1. compile the events after the web page is loaded; 2. jQuery selector usage; 3. jQuery obtains/modifies TAG content and obtains/Tag attribute values. 4. jQuery hide/display tags 5. jQuery adds Click... syntaxHighlighter.

Today is my first day of learning jQuery. The main learning content is as follows:

1. Compile the events after the web page is loaded;

2. How to Use the jQuery selector;

3. jQuery obtains/modifies TAG content and obtains/Tag attribute values;

4. jQuery hide/display tags

5. jQuery's method of adding a Click event to a tag

Learning Experience:

1. How to automatically hide/display tag Blocks

Idea => set a custom attribute for the hide/Show button, as shown in the following code:The operation attribute of is customized. It has two values ('hide '/'show') and the default value is 'hide, use jQuery to change the value once (between the two values of hide and show). When hiding or displaying a tag block, you only need to determine the value of the operation attribute.

In addition, we will introduce jQuery's simple method for implementation:

$ ('Input # toggleaction'). click (function (){
$ ('Div # hideOrShowDiv '). toggle ();
});

It's so easy...

2. Get/set the value of a tag attribute
$ ("Tag"). attr ("attribute name"); // get the attribute value

="

$ ('Div '). attr ('id ');

$ ('Div # idname'). attr ('id ');

$ ('Div. classname'). attr ('id ');

$ ("Tag"). attr ('Property name', 'Property attribute'); // set the property value

="

$ ('Div '). attr ('id', 'xxvalue ');

$ ('Div # idname'). attr ('id', 'xxvalue ');

$ ('Div. classname'). attr ('id', 'xxvalue ');

3. Usage of hide () & show ()
Hide tags: $ ('tagname'). hide ();

Show tags: $ ("tag name"). show ();

4. Obtain the tag Text Value
$ ('Div # hideOrShowDiv '). text ()

5. Insert text to a specified tag
Condition ('div=hideorshowdiv'{.html ("contentValue ");

------------------------------- The code is pasted here for your reference. It is not well written and mainly used for your own learning ------------------------------
 
  
 
 
JQuery Practice 1: The Write Less, Do More, JavaScript Library 
 
 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.