[Jquery] returns the fn of a rowspan.

Source: Internet
Author: User
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> 

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.