JQuery Study Notes 2

Source: Internet
Author: User
Tags to domain

18. node operations
1. Replace <br/> with $ ("Br"). replaceWith ("2. Wrap nodes in red and then in bold
$ ("P"). wrap ("<font color = 'red'> </font> ");
$ ("P"). wrap ("<B> </B> ");
19. style operations
1. Get the style attr ("class ")
2. Set the style attr ("class", "myclass ")
3. append style addClass ("myclass ")
4. Remove the style removeClass ("myclass ");
5. toggleClass ("myclass ");
6. Determine the style hasClass ("myclass ")
Body * indicates all controls in the body.
The instance style is defined by yourself.
$ ("# Div1"). addClass ("day ");
$ ("# Div1"). addClass ("night ");
$ ("# Div1"). removeClass ("night ");
$ ("# Div1"). toggleClass ("night ");


21. multiple versions of IECollection can be used according to IE

22. RadioButton operation
1. Obtain the RadioButton value.
$ ("Input [name = gender]: checked"). val ();
2. Set the value of RadioButton (the value of [] in two methods of val cannot be less)
$ ("Input [name = gender]"). val (["male"]);
$ (": Radio [name = gender]"). val (["male"]);
CheckBox operations
Get the CheckBox Value

Set the val in the CheckBox. The value of the checkbox value is not the value written at the end.
$ (": Checkbox"). val (["basketball", "soccer", "Table Tennis 1"]);


24. JQuery events

1. bind events
$ ("# Btn"). bind ("click", function () {}) is abbreviated as $ ("# btn"). click (function (){})
2. hover abnormal Writing of merging events hover (enterfn, leavefn)
3. Event bubbling JQuery also has event bubbling from the inside out
4. stop bubbling stopPropagation (); pass parameter e to anonymous function to call StopPropagation
5. prevent default behavior preventDefault () Root window. event. returnValue = false.
6. pageX and pageY: x and y coordinates when the screen is clicked
Target obtains the element of the trigger event, which is equivalent to the original control triggered by srcElement.
7. which: key used to interpret mouse events (1. left-click 2, middle-click 3, and right-click)
8. altKey, shiftKey, and ctrlKey are used to obtain whether alt, shift, and ctrl are pressed as bool values.
9. keyCode charCode when an event occurs in the keyCode and charCode attributes (the same is true for the primary and secondary keycodes)
10. Remove the unbind () method of event binding to remove all events bound to the element. If unbind ("click"), only the click event is removed.
11. one-time event occurs once.
 
 
 
$ (Function (){
$ ("# TbMain"). click (function () {alert ('tbmain ');});
$ ("# Tr1"). click (function () {alert ('tr ');});
$ ("# Td1"). click (function (e) {alert ('td '); e. stopPropagation ();});
$ ("# P1"). click (function () {alert ('p1 ');});

});
$ ("A"). click (function (e) {alert ('link is not connected'); e. preventDefault ();});
// One-time event
$ (": Button"). one ("click", function (){
Alert ("I can only trigger once ");
});
26. Mouse
1. Get the mouse position

$ (Function (){
$ (Document). mousemove (function (e ){
$ ("# Fly" ).css ("left", e.pageX).css ("top", e. pageY );
});
});

<Div id = "fly" style = "position: absolute">


</Div>
28. Animation
1. The toggle switching parameters of the show () and hide () methods are the hidden milliseconds.
 
QQ effect for instances
$ ("# Ulqq li: odd"). addClass ("body ");
$ ("# Ulqq li: even"). addClass ("header"). click (function (){
$ (This). next ("li. body"). show (400). siblings ("li. body"). hide ();;

});
$ ("# Ulqq li: first"). click (); // simulate the click element

Thirty. JQuery Cookie JQuery plugin
1. Cookie is the content stored on the client browser.
2. Cookie must be supported by the browser
3. Cookie related to Domain Name
4. The Cookie will be automatically cleared by the browser, and the user may manually clear it.
5. Store unimportant data with cookies
 
. JQuery Cookie usage (the Cookie stores key-Value Pair parameters for query)
1. Add a reference to jquery. cookie. js.
2. Set the value $. cookie ('name', 'value'); cookie stores text
3. Read value $. cookie ('name ');
4. It can also be read from another page of the same domain name.
5. expires: 7 indicates that the browser is saved for several days.
6. domain: Set second-level domain names to read from each other
7. set which pages of the website can be read using path
// Read
Alert ($. cookie ("username "));
// Set
$. Cookie ("username", "tom ");
35. JQueryUI is called directly when it is very useful.
1. JQuery plug-ins can be used to set many things.
2. http://jqueryui.com/download the Demo here
36. Introduction to web development Auxiliary Tools
1. Internet Explorer Developer ToolBar



Author liyangfd

Related Article

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.