Jquery learning Day 1

Source: Internet
Author: User

Positioning element:
Principle: Mark as class corresponding. Mark as ID corresponding #

$ (); If no mark is provided to indicate all elements, locate the element with equal class and
Elements with the same ID
Multiple tags in the same element are written together, for example, $ ("P # p2") $ ("input: button # B2 ")
Multiple internal tags of different elements are separated by spaces or> such as $ ("# Div P") $ ("# Di> P ")

Method:
Add Element
Append -- appendto --- after
Append appendto is inserted into the element, but "opposite position"
After is inserted outside the element.

At the same time, before is opposite to after.
Clildren all unique child element sets of each element. When multiple elements exist, the first element is used by default unless children ("# A") is specified.
Same as before.
Clone () clone matched elements
Click contains to select elements and leave matching elements. --- It seems that it cannot be used. Empty deletes all matched elements, which are opposite to contains.
Each traversal element,
$. Each traverses elements, including objects and data, with a wider range than each.

End ends the current operation and returns the previous operation $ ("# divs "). find ("# Pa" ).end().css ("background", "#33 ccdd"); if the background color of divs is set,
It is not the background color of PA.

Animate Animation

ATTR obtains the attribute value of an element, sets a single attribute value of an element, and sets multiple attribute values of an element.
Principle: For a single attribute name and method, "" is used for reference,
For multiple attributes, use {} to package the entire package, and then use "Reference" to reference the value,
Use between attributes and values: use between attributes. If the two attributes are the same, the subsequent values will replace the previous values.

The value can be a specific value, a function, or a method. You can call the attributes of other elements. If you call your own attributes, you can use this abbreviation.

BIND is the boss click, blur, change, dblclick, error
Here, a very important concept is provided. The event handler function returns false to block browser behavior. If I click a hyperlink, the page is not forwarded.

 

Browser check browser settings

CSS gets the style and sets the style. The rule is the same as that of ATTR.



-======================================

$ (Document). Ready (function (){

Alert ("START ");
/* $ Usage */
// $ ("<Span> Hello <span>"). appendto ("# e"); // Add a dynamic HTML Element
// $ ("# S"). appendto (". d"); // Add an existing HTML Tag

/* $ ("Love"). appendto (". d"); * // Add a string, Error!

// $ ("# Di"). Hide ();
// $ ("# Di> P"). Hide ();
/// $ ("# Di P"). Hide (); // The three effects are the same.

// $ ("Div P"). Hide ();
// $ ("Div> P"). Hide (); // the two effects are the same.

// $ (Document). Find ("Div P"). Hide ();
// $ (Document). Find ("div> P"). Hide ();

// $ (Document). Find ("# Di> P"). Hide ();
// $ (Document). Find ("# Di P"). Hide ();
// $ (Document). Find ("# Di"). Hide (); // five methods are the same as the preceding five methods

// $ ("Input"). Hide ();
// $ (Document). Find ("input"). Hide ();
// $ ("# T1"). Hide ();
/// $ (". T2"). Hide (); // the usage of other elements is the same as that of the preceding element, which is mainly used to determine the elements of the class and ID.

// Configure (document.body).css ("background", "#33 ccdd"); // set the page background
// $ (Document. Body). Hide (); // hide all text tags on the page-= --
// $ (Form1). Hide (); // hide all elements on the page
/// $ (Form1.elements). Hide (); // hide all elements on the page, just as above

// $ ("Input: button"). Hide (); // hide the elements whose input is a button
// $ ("Input: button # B2"). Hide (); // hide elements whose input is a button and whose ID is B2
// $ ("Input: button. B"). Hide (); // hide the elements whose input is a button and whose class is B
/* Class ----------.; Id -----------#*/
/* Unclear about add usage */
// $ ("P"). addclass ("PSE"); // the CSS attribute is.
// $ ("# P2"). addclass ("Limit 2 ");
// $ (". P1"). addclass ("Limit 2 ");
// $ ("P. P1"). addclass ("Limit 2 ");
// $ ("P # p2"). addclass ("Limit 2 ");
// $ (Document). Find ("# p2"). addclass ("Limit 2 ");
// $ (Document). Find (". P1"). addclass ("Limit 2 ");

// $ ("# Divs # Pa"). addclass ("Limit 2 ");
// $ ("# Divs P # Pa"). addclass ("Limit 2 ");
// $ ("# Divs> P # Pa"). addclass ("Limit 2 ");
// $ ("# Divs> P # Pa"). After ("<span> Hello <span> ");
// $ ("# Divs> P # Pa"). After ($ ("# T1 "));
// $ ("# Divs> P # Pa"). After ("<p> three </P> ");

// $ ("# Pa"). After ("# T1"); // insert it outside the element
// $ ("# T1"). appendto ("# Pa"); // insert it into the element

/*
Positioning element:
Mark as class. Mark as ID #
$ (); If no mark is provided to indicate all elements, locate the element with equal class and
Elements with the same ID
Multiple tags in the same element are written together, for example, $ ("P # p2") $ ("input: button # B2 ")
Multiple internal tags of different elements are separated by spaces or> such as $ ("# Div P") $ ("# Di> P ")
Method:
Appendto after
The function is the same, but appendto is inserted into the element, and after is inserted outside the element.
*/
// $ ("# P3"). animate ({
// Height: 'toggle ', opacity: 'toggle'
//}, "Slow ");

// $ ("# P3"). animate ({
// Left: 50, opacity: 'show'
// }, 500 );
// $ ("# P3" ).css ("color", "Red ");

// $ ("<Span> Hello <span>"). appendto ("# P3 ");
// Alert ($ ("# P3"). ATTR ("ID "));
// $ ("# P3"). ATTR ("style", "color: red; color: Blue ");
// $ ("# P3"). ATTR ({style: "color: Red", style: "font-weight: bold "});

// $ ("# P3"). ATTR ("style", "color: red; font-weight: bold ");

// $ ("IMG "). ATTR ("title", function () {return $ ("IMG "). ATTR ("src")}); // returns the relative path.

// $ ("IMG"). ATTR ("title", function () {return this. SRC}); // return the absolute path

// $ ("IMG"). ATTR ("title", "$ {This. SRC}"); // no longer available

// $ ("# P3"). BIND ("click", function () {alert ("DD ");});
// $ ("# A1"). Click (function (event) {event. preventdefault ();});
// $ ("# A1"). Click (function () {return false ;});

// $ ("# T1"). Blur (function () {alert ("DDD ");});
// $ ("# T1"). Blur ();
// Alert ($ ("# divs"). Children (). ATTR ("ID "));
// Alert ($ ("# P3"). Clone (). ATTR ("ID "));

// $ ("# P3"). Clone (). appendto ("# p1"); // The element tags are the same and cannot be seen
// Alert ($ ("p"). Contains (""));
// $ ("IMG"). Each (function (I) {This. src = "test" + I + ". jpg "})
// Var A = [8, 96, 5, 3];
// $. Each (A, function (I, n) {alert (I + "-" + n )})

// $ ("p "). empty ();
// $ ("# divs "). find ("# Pa" ).end().css ("background", "#33 ccdd");
// $ ("p "). eq (1) // do not understand what it means, and it is best not to use it.

})

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.