120 days of 1200 hours of communication with students in junior school. NET (eight) about jquery

Source: Internet
Author: User

Anonymous functions are especially important

1,jquery is the JS syntax to write some of the functions, the interior is still implemented with JS, so it is not a substitute for JS. Using jquery's code, the development plugin for jquery still requires JS technology, and JQ itself is a bunch of JS functions;

2, to the method that uses JQ, must pass the $ object. Only the normal DOM is encapsulated as a JQ object to invoke the JQ various methods

$ is a JQ shorthand, and the code can use jquery instead of $

3, write comments, subsequent JQ code will be more and more, comments are necessary

4,JQ file Normal version is development use, compressed version is released using

5,dom object can be transferred to JQ object, JQ object can also go DOM object $ (DOM object)

6,onload refers to the execution of a page after all content is loaded

ready means that the Basic tab of the page is loaded and executed
Usually use $ (function () {* *});

7, we recommend each traversal key-value pairs, map traversal array

8, there is a trim method.

The 9,dom attribute, which is generally changed into a method in JQ

10,

Multi-Criteria Selector
$ (' p, #dv,. CLS ')
Hierarchy Selector
$ (' div p '). CSS ()
The elements p of the layer, and the child elements p are all changed

$ (' div>p '). CSS <strong><p></p></strong> Invalid for <p><p></p></p> valid

Below the layer directly next to the Brother element P takes effect.
$ (' div+p ')


$ (' div-p ')//layer after all P tags are in effect (brother) nephew nephew does not take effect
<div></div>
<p></p>
<p></p>
<span><p></p></span>/////invalid

11,

$ (' div '). Next (). CSS ()//Get the first sibling element after the current element

. Nextall ()//All subsequent direct elements, grandchild layer elements are not included (but include p nested p)
. Prev () The first sibling element in front of the current element
. Prevall ();
. Siblings current element all sibling elements, including grandchild elements
**************
$ (' P '). length determines whether an element exists

************
Adding class Styles
$ (' div '). addclass (' CLS ') class without adding

Remove class Style
$ (' div '). Removeclass (' CLS ')
***********
$ (body). Toggleclass (CLS); Switch to a CLS-free class style (such as a video switch light)

12,

$ (' P eq (2) '). CSS ()//Get elements based on index (subscript)

$ (' P LT (2) '). CSS ()//index of two elements less than 2

$ (' P GT (2) '). CSS ()//element with index greater than 2

13,

Basic Filter Selector
$ (' Div:first ')
$ (' div '). First ()
$ (' div:last ')
$ (' div '). Last ()

$ (' Div:even ') index is an even number

$ (' div:odd ') index is an odd number

14,

Star scoring effect code:
$ (function () {
$ (' #tb TD '). MouseOver (function () {
$ (this). Text (' Solid star '). Prevall (). Text (' Solid star ');
}). mouseout (function () {

$ (this). Text (' Hollow Star '). Siblings ();
});
});

120 days of 1200 hours of communication with students in junior school. NET (eight) about jquery

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.