Under Jquery: nth-child (an + B) Usage Note _ jquery

Source: Internet
Author: User
Today, I started to learn how to use JQuery to create a dynamic table. The structure is as follows:
The next two classes are empty to adjust the column width for the columns that may increase.
$ ("P> p "). parent (). not ($ (". grid_2 ")). filter ("nth-child (" + lenth + "n + 1)") to select the 2nd columns of each row, but select the third column.
By using firbug to query this element, we have no intention to find that the nodeindex (nodeindex is in the same order as the element in the same level) under the element is the same as the value calculated by the parameter an + B, I used to directly use nodeindex to select 2nd columns, but I don't know how to do it.
I checked Baidu and found that nth-child is also using nodeindex. The specific implementation is as follows:

The Code is as follows:


Filters :{
// For example, $ ("input [name ^ = 'News']") [ ]
ATTR: function (elem, match ){
Varresult = Expr. attrHandle [match [1]? Expr. attrHandle [match [1] (elem): elem [match [1] | elem. getAttribute (match [1]), value = result + "", type = match [2], check = match [4];
Returnresult = null?
Type = "! = ":
Type = "= "?
Value === check:
Type = "* = "?
Value. indexOf (check)> = 0:
Type = "~ = "?
("" + Value + ""). indexOf (check)> = 0:
! Match [4]?
Result:
Type = "! = "?
Value! = Check:
Type = "^ = "?
Value. indexOf (check) = 0:
Type = "$ = "?
Value. substr (value. length-check.length) === check:
Type = "| = "?
Value = check | value. substr (0, check. length + 1) = check + "-":
False;
}
}


Originally: nth-child (an + B) is based on Under the parent element of the element(That is, the child element will be selected from the parent element of your current element), instead of selecting the nth child element in the remaining element

Therefore, if I use. not to filter out the first column, the second column of nodeindex = 2 cannot be "the first column"

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.