Hide a table row by JavaScript

0

I would like to know how to show and hide an entire row of a table in PHP using javascript or another function.

I used this function, but when I use it in a onclick , the line to which it was hidden appears always in the first cell of the previous line.

JavaScript Function

function Mostrar(obj) {
    var display = document.getElementById(obj).hidden;
    if(display == true)
        document.getElementById(obj).style.display = 'none';
    else
        document.getElementById(obj).style.display = 'block';
}

The table to which I would like to hide the line, is inside a loop for where I have the sum of several expenses of a certain process, and the line that will be hidden should contain the detailed expenses of this process. >     

asked by anonymous 08.11.2017 / 19:51

1 answer

0

I usually do this:

$("#tabela").on("click",".deletaLinha", function() {
                var tr = $(this).closest('tr');
                tr.css("background-color","yellow");
                tr.fadeOut(600, function(){
                    tr.remove();
                });
                return false;
            });

Then in the table I put a link like this:

<td><a class='deletaLinha' href='#'>Remover</a></td>
    
08.11.2017 / 20:08