As an example,
var arr = $ (' #table tbody tr td:nth-child (2) ')//the TD in the table is located in order of the ID, followed by the second value for each column. Map (function () {return $ (this). Text ()})//Make Each TD is processed with a map, function is a callback function, and the Text.get () of each element is returned; Convert an object collection to an array Additionally, you can also follow the. Join (",") this will be converted to a string.
There is a concept called "class array" under jquery, such as $ ("Li"), when a collection is taken, there are some properties of the array, but the instancseof array is still false. But Var a=$ ("Li"). Get () to handle this, and then instancseof the array to return true.
Be aware of the Var a=$ ("Li"). Get (1) inside the serial number can be taken to a single element, the nature of these elements is not a jquery object, but the JS object, so do not directly use the jquery method.
The function of map () is mainly two steps, the first step is to traverse, the second step is to replace.
$ ("Li"). Map (function () {
return $ (this). text (); Note that the return keyword is not limited
} )
The map iterates, each item returns a text () value, and the map automatically replaces each item value of the $ ("Li") collection, so this is an array of classes (because it is still a shell of $ ("Li"), not a real array. So the addition of a get () operation becomes a real array, so you can use join () as an array-specific method.
Such as:
$ ("Li"). Map (function () {
return $ (this). text ();
}). Get (). Join ("%")//stitch into a string, separated by "%" in the middle
Nth-child (2) Select the first few tags, the numbers inside can be what you want
Nth-child (N+4) selects a label greater than or equal to 4, and "n" represents the integer
Nth-child (-n+4) Select less than or equal to 4 labels
Nth-child (2n) Select even label, 2n can also be even
Nth-child (2n-1) selects odd labels, 2n-1 can be odd
Nth-child (3n+1) custom selection label, 3n+1 means "two take one"
Last-child Select the last label, same as First-child
Nth-last-child (3) Select the last number of labels, 3 means to select a 3rd
JQuery gets the data in the table