120 days of 1200 hours of communication with the junior students. NET (ix) about jquery

Source: Internet
Author: User

Finishing the JQ basis commonly used (too basic to spray):

1,

$ (' div input[name] '). CSS (', ');//Gets a label with the name attribute in the layer

$ (' div input[name=txtname] '). CSS (', ');//Gets the label with the name attribute in the layer with the property value Txtname

$ (' div input[name! =txtname]. CSS (",");//Gets the name attribute in the layer, and the property value is not the input label of the Txtname

$ (' div input[name^=n] '). CSS (', ');//gets all input tags with the name attribute in the layer and the Name property value N

$ (' div input[name$=e] '). CSS (' ', ');//gets all input tags with the name attribute in the layer and the Name property value of N.

$ (' div input[name*=e] '). CSS (', ');//Gets the name attribute in the layer, and the Name property value is all input tags that contain n

$ (' div input[name][value] '). CSS (', ');//Gets the label with the name and Value property in the layer

2,

$ (' div:d isabled '). CSS (', ')//Gets the disabled element in the layer

$ (' input:checked '). CSS (', ')//Get elements with checked property values such as a checkbox
Selected//Selected

If there is a space to get an element in an element
If there is no space to get an element that has such an attribute

3, check the checkbox code ****************

$ (function () {

$ (' div input[type=checkbox] '). Click (function () {
var cks = $ (' div:checked ');
var len = cks.length;
var arr = [];
Cks.each (function (k, v) {//k Index, V is the value
Arr[arr, Length] = $ (v). Val; At the beginning of the array length is 0, then the index is 0 of the stored value
After the value is stored, the array length increases, and so on ********
});
$ (' #sp '). Text (' Total selected ' + Len + ', respectively: ' + arr ');
});
});

4,

$ (': input ') Select all <input><textarea><select> elements
$ (' input ') only get <input>

5,

$ (': Text ') selects all single-line text boxes, equivalent to $ (' input[type=text] ')
Also $ (':p asswprd '): Radio:checkbox:submit:image:reset:file:hidden instead of $ (' input[type=***] ')

6, Content Filter

$ (' Div:contains (content) ')//Get the layer containing this content

$ (' div:empty ')//Get empty layer

$ (' Div:has (a) ')//Get the layer containing this label

7, Sub-element filter:

$ (' ul Li:first '). CSS (', '); //Get page All Li's first li is the first one of UL

$ (' ul li:first-child ')//Get page each UL first Li

and Last-child.

8,

$ (function () {
$ (' Btnall '). Click (function () {
$ (': checkbox[name=name1] '). attr (' checked ', true); attr setting the attributes and values of the selected element
});
$ (' Btnfanxuan '). Click (function () {
$ (': checkbox[name=name1] '). each (function (k,v) {
$ (v). attr (' checked ',!$ (v). attr (' checked '));
});
});
});

9,

$ (' div '). attr (' class ', '. CLS ')//Add Class style
$ (' div '). attr (' class ', ');//Remove class style
$ (' div '). Remove (' class ')//Remove style (recommended)

10,$ (' <div></div> '). Appendto (' body ');

Prependto (parent Element) is actively added to the first

A.insertbefore (b) by adding A to B before the equivalent of B.before (a);
X.insertafter (y) adds X to the back of Y, equivalent to Y.after (x);

11,

Empty the layer $ (' div '). empty ();

Remove ('. CLS ')//Remove the application. CLS This class-style element

12,

Please read the agreement carefully (10)

$ (function () {
var time = 5;
SetInterval (function () {
Time-= 1;
if (time <= 0) {
$ (' #btn '). Val (' consent '). attr (' disabled ', false);
} else {
$ (' #btn '). Val (' Please read carefully (' + Time + ') ');
}
}, 1000);
});

13,.unbind (); Clear All Events

14,

$ (' BR '). ReplaceWith ('

$ (' <br/> '). ReplaceAll (' hr '); Replace all HR in a page with a BR tag

15,

Parcel nodes
$ (' div p '). Warp (' <strong></strong> ');//each P tag in the layer is wrapped up

. Wrapall ()//layer all P wraps a label
. Warpinner//All contents tagged with label

16,

Radio checkbox to use each

a TTR () method, two parameters represent the value of setting a property, and one parameter is getting the value of this property

120 days of 1200 hours of communication with the junior students. NET (ix) 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.