I am now searching all over the net on the net, but I still can not figure it out.
& lt; Table & gt; & Lt; TR & gt; & Lt; Th class = "name" & gt; Name & lt; / Th & gt; & Lt; Th class = "age" & gt; Age & lt; / Th & gt; & Lt; Th class = "nick" & gt; Nick & lt; / Th & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; John & lt; / TD & gt; & Lt; TD & gt; 30 & lt; / TD & gt; & Lt; TD & gt; Johnny & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Robert & lt; / TD & gt; & Lt; TD & gt; 35 & lt; / TD & gt; & Lt; TD & gt; Bob & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
Is there any way to tag classes with those headers to tag TD in the same column?
I will do it like this: This is effectively the same Note: You must add an index to the index because the index is
$ ("Table th") each (function (i, val) {var var = $ (this); var selector = "td: nth-child" (+ + (i + 1 + +)); th.parent () . Sister (). (Selector) Search .attr ("class", th.attr ("orbit");});
& lt; Td>
is used to get every ()
on
: nth-child ()
is one-based. In addition to this, you can not select the : eq
reference as it matches only one element.
No comments:
Post a Comment