jquery Learning Document Notes

Source: Internet
Author: User

1. Events not seen:

The difference between Focusin and the focus event is that he can detect a child's focus on the parent element.

The difference between the Focusout and the Blur event is that he can detect when a child element loses focus on the parent element.

2. Using the Wrapall method

Examples are as follows

Original code:

<div class= "MM" ><p> we are in the company </p></div>
<div class= "MV" >
<p> we are in the company </p>
<p> we are in the company </p>
<p> we are in the company </p>
</div>

jquery Operation: $ ("P"). Wrapall (' <div class= ' test ' ></div> ');

Output code:

<div class= "MM" >
<div class= "Test" ><p> we are in the company </p>
<p> we are in the company </p>
<p> we are in the company </p>
<p> we are in the company </p>
</div>
</div>
<div class= "MV" >
</div>

Summarize:

This method moves all P tags to the position where the first P-label appears and appendto it to <div class= "test" ></div>

3, for the use of detach methods:

Description: The Remove () method removes all event handlers and other data that may be bound to the removed element. The detach () method and the Remove () NVC, but does not remove the event handlers and data. Detach may be more useful if you want to temporarily remove elements from the document so that they can be inserted again later.

Case:

HTML code:

<a class= "Clickelm" style= "display:block;width:100px;height:20px;line-height:20px;text-align:center; Background: #e1e1e1; " > Click me </a>

<a class= "clickElm2" style= "display:block;width:100px;height:20px;line-height:20px;text-align:center; Background: #e1e1e1; " > Click on my 2</a>

jquery Operations:

var $clickElm = $ (". Clickelm"),
$CLICKELM 2 = $ (". clickElm2")

;
$clickElm. attr ("PPP", "999");
$CLICKELM 2.attr ("PPP", "999");
$CLICKELM. Click (function () {
Alert ($ (this). attr ("PPP"));
});
$clickElm 2.click (function () {
Alert ($ (this). attr ("PPP"));
});
$clickElm. Detach ();
$CLICKELM 2.remove ();


SetTimeout (function () {
$clickElm. AppendTo ("body");
$CLICKELM 2.appendTo ("body");
},15000);

Results:

<a ppp= "999" class= "Clickelm" style= "display:block;width:100px;height:20px;line-height:20px;text-align:center; Background: #e1e1e1; " > Click me </a>
<a ppp= "999" class= "clickElm2" style= "Display:block;width:100px;height:20px;line-height:20px;text-align:center ; background: #e1e1e1; " > Click on my 2</a>

A tag with the class name "Clickelm" appears again after it disappears for 15 seconds, and can respond to a click event, and a label with the class name "ClickElm2" appears again after 15 seconds, but cannot respond to the Click event, and the value given by the attr function is still present in the element

jquery Learning Document Notes

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.