[jQuery] Re: Getting Last ID

2009-09-30 Thread lionel28
Thanks. The first row is always there. It cannot be removed if it's only one row. However, I just realized that the code that I am using is not jQuery function addNewRow(newId) { var tbody = document.getElementById('list').tBodies[0]; var lastRow = tbody.rows.length - 1; var newId

[jQuery] Re: Getting Last ID

2009-09-30 Thread Dave Methvin
> What is the best method to get the last ID so I have > > 1 > 3 > 4 Here's my untested solution: function addNewRow() { var $tbody = $("#list tbody:first"); var newId = +($tbody.find("tr:last").attr("id") || "0") + 1; var $row = $("").attr("id", newId).appendTo($tbody); ... } If there