Hide row from a table by Javascript

Asked

Viewed 96 times

0

I would like to know how to show and hide an entire row from 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 always appears whole 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 particular process, and the line that will be hidden should contain the detailed expenses of this process.

  • 1

    "Java"? Remember that Java and Javascript are very different things.

1 answer

0

I usually do like this:

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

Ai in the table I put a link like this:

<td><a class='deletaLinha' href='#'>Remover</a></td>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.