[jQuery] simple test: dynamically add a row to table
Hi,
I'm trying to do a fairly simple test, add a row to a table using
jquery. My web page has a table with two rows. The idea is that when
a user clicks on the last (second) row, the last row is cloned and
appended to the table...this is useful if a user needs to enter lots
of data in a table (I believe MS Acces does this).
Following is my function:
<script>
$('#lastrow').click(function(){
alert(this);
this.after(this.cloneNode(true));
});
</script>
When I run it, I get the alert (table row element), but nothing else
happens. I'm using firefox with firebug (macintel laptop), but I
don't see any errors.
Below is my whole web page code, what am I doing wrong? Thanks in advance.
---------------------
<html>
<head>
<!--script src="http://jquery.com/src/latest.js"></script-->
<script src="../jslibs/jquery.js"></script>
</head>
<body>
<div>
<table width="95%" border="1">
<tr>
<th scope="col">Table Name </th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
<tr id="lastrow" >
<th scope="row"> </th>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</body>
<script>
$('#lastrow').click(function(){
alert(this);
this.after(this.cloneNode(true));
//this.css('color', '#c00');
});
</script>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/