Hiding element inside a menu

0

I have a menu like this ..

<div class="btn-group">
    <button type="button" class="btn btn-danger vermDigifred btn-xs dropdown-toggle glyphicon glyphicon-pencil" data-toggle="dropdown"> </button>                                           

    <ul class="dropdown-menu" role="menu">
        <li  ><a id="btnExcluirRegistro" ng-click="excluirDistritos(dis)"><span class="glyphicon glyphicon-trash"></span> Excluir registro</a></li>
        <li > <a id="btnAlterarRegistro" data-toggle="modal" data-target="#modalAlterarDistrito" ng-click="alterarDistritos(dis)" ><span class="glyphicon glyphicon-edit"></span> Alterar registro</a></li>
    </ul>
</div> 

I want to do a function in Js to hide the a tag if, for example, delete = 1

    
asked by anonymous 26.10.2017 / 14:06

1 answer

2

This code should do what you're looking for, it will hide all the a tags on the page.

const esconder = function(excluir) {
    if (excluir === 1){
        let a = document.getElementsByTagName('a');
        for (let i = 0; i < a.length; i++){
            a[i].style.visibility = "hidden";
        }  
    }
};

Remembering that you need to define where this excluir comes from

    
26.10.2017 / 14:43