Home > Web Front-end > JS Tutorial > Implementation ideas for adding rows and deleting rows in jquery tables_jquery

Implementation ideas for adding rows and deleting rows in jquery tables_jquery

WBOY
Release: 2016-05-16 17:39:45
Original
869 people have browsed it

Share the situation encountered in the background

Copy the code The code is as follows:

< ;!DOCTYPE html>


Add rows and delete rows in table



<script> <br> $(function(){ <br>var show_count = 20; //The number of items to be displayed<br>var count = $("input:text").val(); //The starting value of increment, here is your ID <br>var fin_count = parseInt(count) (show_count-1); //Condition for ending increment <br>$("#btn_addtr").click(function(){ <br>if(count < fin_count ) //When clicked, if the current number is less than the increment end condition <br>{ <br>$("tr:eq(1)").clone().appendTo("table"); //After the table Add a row <br>$("tr:last td input:first").val( count); //Change the ID value of the added row <br>} <br>}); <br>}); <br>function deltr(){ <br>var length=$("tr").length; <br>if(length<=2){ <br>alert("Keep at least one line"); <br>}else { <br>$("tr:last").remove(); <br>} <br>} <br></script>


















ID Username Usertype Other
< ;input type="text" name="username" />


< ;/body>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template