Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
Jquery If condition True add style visibility:hidden

I'm trying, if an "if" condition is true, to set the style of an element to "visibility:hide;".

I've done this:

if (user.privilege = 3) {
        $("#persone").css("visibility:hidden;");
}

But when the If condition runs, in the console i get this error:

"Uncaught TypeError: Cannot read properties of null (reading 'style')"

What should i do to solve this?

var html = '<div class= "col-lg-6">'+
           '<label class="mt-15">A chi è riferito l\'evento? </label>' +
                 '<select class="form-control" id="persone" >' +
                    _this.GetOptionPersone() +
                 '</select >' +
           '</div>' ;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You've got a couple of syntax issues. Firstly = is for assignment. To compare values you need to use == or ===.

Secondly css() accepts 2 arguments, the rule name and its value, and it shouldn't have the trailing ;.

if (user.privilege == 3) {
  $("#persone").css('visibility', 'hidden');
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda