ArticleDirectory
- Starting from
- Program
- Save as Js for future use
- Use him
Starting from
Today, I have a requirement. I have a temporary table for rowspan. The program is ASP. If the operator is handled during table production, the program may be more difficult to handle than the operator. As a result, it is easy to use a jquery FN to do this.
Program
The program does not require permission. The caller must be a collection of all objects in the column, and then check through each to see if the content is the same as the previous one, at different times, remember to make rowspan objects, and other objects start with hide. The following is the FN of rowspan.
Jquery. FN. rowspan = function () {var I = 0; var ptext = ''; var sobj; // compute the row rowspan object var rcnt = 0; // calculate the number of rowspan var tlen = This. length; return this. each (function () {I = I + 1; rcnt = rcnt + 1; // It is different from the previous vertex if (ptext! = $ (This). Text () {if (I! = 1) {// It is not starting from the beginning. ATTR ('rowspan ', rcnt-1); rcnt = 1;} // specify the rowspan object sobj = $ (this); ptext = $ (this ). text ();} else {$ (this ). hide ();} if (I = tlen) {sobj. ATTR ('rowspan ', rcnt + 1 );}});}
Save as Js for future use
Save this program as tablerowspan. js to facilitate direct reference in the future.
Use him
here is an example to illustrate how to use it. There are two operators that handle rowspan on the first column and the second column separately. The custom consistency is passed, so that 1st and 2nd columns can be captured easily. The following is a complete program example. When you need to renew the program, save it as an HTM tutorial.
<HTML>