JQuery Common Code

Source: Internet
Author: User

1. Selector

1. Select all the paragraphs in the document according to the tag name: $ (' P ')
2. By ID: $ ("#some-id")
3. Class: $ ('. Some-class ') $ ('. tab curr '). Removeclass ("Curr");.

$ (' tr:odd '). addclass (' odd '); Filter the odd elements in the selection result set

$ (' Tr:even '). addclass (' even '); Filter even elements in the selection result set

2, this

Onclick= "Changestate (); $ (this). addclass (' Curr ')"

3. Hide and Show

$ (' #some-id '). Show (); No effect, will automatically record the original display property values (such as: block, inline), and then reply to the display value
$ (' #some-id '). Hide ();   No effect, equivalent to: $ (' #some-id '). CSS (' Display ', ' none '); Hiding elements, not preserving physical locations
The display or concealment of a gradual change in size and transparency
$ (' #some-id '). Show (' slow '); Specifies the display speed at which the height, width, and opacity of the element are gradually increased to the attribute value, with the following: Slow is 0.6 seconds, normal is 0.4 seconds, fast is 0.2 seconds, or the number of milliseconds is filled in directly
$ (' #some-id '). Hide (800); As with the. Show () specifies the speed display, the height, width, and opacity of the specified time are gradually reduced to 0
Fade in and fade
$ (' Some-id '). FadeIn (' slow '); The Opacity property value is increased from 0 to 1 in the specified time
$ (' Some-id '). FadeOut (' slow '); The opacity value is reduced from 1 to 0 within the specified time

4, var textval = $ ("#text_id"). Val ();

5. Remove elements from matching elements, like empty elements
$ (' #some-id '). empty ();


6. Remove the matched element and its descendant elements from the DOM
$ (' #some-id '). Remove ();

JQuery Common Code

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.