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

123
Visualizações
change css based on js variable

I am passing a variable called editable from my backend, which holds true or false as the variable. once it is passed to the front end, i have access to it. I want to do something like this:

if ('<%= editable %>' == true) {
 //change the input tag (in css) to be able to be edited.
}

i have this code in the <style> tag:

input {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;  
}

how can I do this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Appreciate everyone's comments. I have figured out a very viable solution for this, hopefully it can help everyone in the future.

function test () {
  if ('<%= editable %>' != 'yes') {
    var x = document.getElementsByTagName("input");
      for ( var counter = 0; counter < x.length; counter++){
         x.item(counter).readOnly = true
      }
   }
}

and then onload="test()" in the body tag.

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