Q
Q
qo_0p2015-11-19 23:28:10
css
qo_0p, 2015-11-19 23:28:10

How to correctly delete the last row of a table?

Hi all.
The question is, I have an HTML table where I delete rows with this function:

function DeleteRow(rowNo) {
        document.getElementById("Table").deleteRow(rowNo);
    }

If I delete rows from the middle of the table, then everything is fine.
But if I delete the last row of the table, an Uncaught TypeError: Cannot read property 'style' of undefined
error occurs. Tell me how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
qo_0p, 2015-11-20
@qo_0p

Understood. I deleted the line through my context menu, which was called by clicking on the desired line. And there is a function that keeps track of the line I click on and highlights it with color through styles. After that, I click on another line, the selection on the previous line is removed through styles. And when the previous line is removed, this error occurs. The function cannot find the styles of the removed element.

V
VanKrock, 2015-11-19
@VanKrock

Do you have the last one is n-1?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question