1

I'm printing table using function:

   function findL(val){
var i;
//alert(splitted + " " + JSDate);
for(i=0;i<jsData.length; i++)
    {
        if(jsData[i].get_date() == val)
            {

                $('<tr>').append($('<td>').html(jsData[i].get_startT))
                .append($('<td>').html(jsData[i].get_endT))
                .append($('<td>').html(jsData[i].get_prow))
                .append($('<td>').html(jsData[i].get_przedm))
                .append($('<td>').html(jsData[i].get_sala))
                .appendTo('#pzTbody');

            }
        }}

As an argument function takes date from datepicker, and when I pick another date it adds to the previously viewed rows. My problem is that I tried plenty ways to cleaning/deleting old rows before next search.

I tried deleteRow(), .parentNode in loop etc. Anyone know how to delete appended rows?

7
  • What is it that identifies the rows to be deleted? Commented Nov 20, 2012 at 12:50
  • $("tr").remove() finds all rows and then removes them, you can make the selector more specific yourself Commented Nov 20, 2012 at 12:50
  • @T.J.Crowder I thought about function clean(tbody) that delete whole table body Commented Nov 20, 2012 at 12:51
  • 1
    You need to rephrase your problem. Commented Nov 20, 2012 at 12:55
  • 1
    What is this search you talk about? Which rows do you want to delete? Old rows? What is old in this case? Commented Nov 20, 2012 at 13:16

1 Answer 1

2

From the code I assuem pzTbody is the id of your table. To clean the table body and remove all rows do this:

$("#pzTbody").empty();

If you just want to remove the last row, use this:

$("#pzTbody tr:last-child").remove();
Sign up to request clarification or add additional context in comments.

1 Comment

Works the way that I wanted to. Thank you very much for help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.