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

119
Visualizações
Javascript to manipulate the data- value inside the label tag

I have been trying to change the data value inside a label, but I can see that setAttribute actually changes the value from the input by adding the data-checked and data-unchecked.

    <div>
      <input type="checkbox" class="toggle" id="default" name="default">
      <label for="default" data-checked="Checked" data-unchecked="Unchecked"></label>
    </div>

This is the javascript that I'm trying to run. Is there a way to modify the label instead of the input?

document.getElementById("default").setAttribute("data-checked","Active");
document.getElementById("default").setAttribute("data-unchecked","Inactive");

Thanks!

about 4 years ago · Juan Pablo Isaza
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