Based on jQuery, click the last row to implement the row auto-Increment Effect. jquery table

Source: Internet
Author: User

Based on jQuery, click the last row to implement the row auto-Increment Effect. jquery table

All transactions are pursuing efficiency and humanization. Of course, the same is true for Web pages. If you can edit a data table and edit it to the last row, you can click here to automatically add a row, this is a more humane effect, you can save a bit of effort, the following is a piece of such code.

The Code is as follows:

<! DOCTYPE html> 

The above Code meets our requirements. Click the last row of the table to automatically Add a new row. The following describes the implementation process.

I. Code comments:

1. $ (function () {}). When the document structure is fully loaded, run the code in the function.
2. var oTable = $ ("# count") to get the object whose id attribute value is count. Here it is the table object.
3. iNum = 1. Declare a variable and assign the initial value to 1. In the future, + 1 can be added as the row number.
4. eEle = '', declare a variable to store row objects.
5. oTable. on ('click', function (e) {}), register a click event handler for the table object.
6. var target = e.tar get to get the clicked source object.
7. oTr = $ (target). closest ('tr ') to obtain the latest tr ancestor element.
8. f (oTr. index () = oTable. find ('tr '). last (). index () to check whether the last row is clicked.
9. iNum ++, iNum value plus 1.
10. eEle = oTr. clone () to clone the object of the current row.
11. eEle. find ('td '). eq (0). text (iNum), set the value of the first cell in the last row.
12. oTable. append (eEle) to add the last row of the table.

All the content of the table for jQuery implementation clicking the last row to implement the row auto-incrementing effect is described in this article. The above content is highly annotated. If you have any questions, refer to it, thank you very much for your support for the customer's home website.

Articles you may be interested in:
  • JQuery-based Spin Button custom text box value auto-increment or auto-Increment
  • Jquery plug-in makes self-growth input box implementation code

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.