My favorites
▼
|
Sign in
lineadecodigo
Web Code Samples in spanish
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
lineadecodigo_web
/
WebContent
/
scripting
/
jQuery
/
add-fila-tabla.html
r478
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Añadir fila a una tabla con jQuery</title>
<script type="text/javascript" src="http://lineadecodigo.com/js/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#add").click(function() {
/* Opción 1 */
var n = $('tr:last td', $("#mitabla")).length;
var tds = '<tr>';
for(var i = 0; i < n; i++){
tds += '<td>nuevo</td>';
}
tds += '</tr>';
$("#mitabla").append(tds);
});
});
</script>
</head>
<body>
<h1>Añadir fila a una tabla con jQuery</h1>
<table border="1" id="mitabla">
<tbody>
<tr>
<td>Dato 1.1</td>
<td>Dato 1.2</td>
<td>Dato 1.3</td>
</tr>
<tr>
<td>Dato 2.1</td>
<td>Dato 2.2</td>
<td>Dato 2.3</td>
</tr>
<tr>
<td>Dato 3.1</td>
<td>Dato 3.2</td>
<td>Dato 3.3</td>
</tr>
</tbody>
</table>
<button id="add">Añadir Fila</button>
<br><br>
<hr>
Artículo disponible en: <a href="http://lineadecodigo.com/2009/05/18/anadir-una-fila-a-una-tabla-con-jquery/">http://lineadecodigo.com/2009/05/18/anadir-una-fila-a-una-tabla-con-jquery/</a><br/>
<a href="http://lineadecodigo.com" title="Linea de Codigo">lineadecodigo.com</a>
</body>
</html>
Show details
Hide details
Change log
r137
by vcuervo on May 18, 2009
Diff
Añadir una fila a una tabla con jQuery
Go to:
...pting/jQuery/add-fila-tabla.html
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1397 bytes, 61 lines
View raw file
Powered by
Google Project Hosting