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

206
Visualizações
Making icons behave as buttons

I have menu icons where I need to make them behave as checkbox (on or off) So When wrap icon is clicked it needs to wrap text and show the color change that wrap is on and when clicked again it would turn off

So I can get rid of traditional checkbox

I have code as

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@38,200,0,0" />

<style>
.menu{
 width:1000%;height:25px;
}
.input:focus{
    width:1000%;
    height:100%;
    outline: none !important;
    border:1px solid #1a73e8;
    box-shadow: 0 0 10px #719ECE;
}
.input{
    width:1000%;
    height:100%;
    outline: none !important;
    border:1px solid #c0c0c0;
    box-shadow: 0 0 1px #719ECE;
}
</style>

<body style="margin:2px;">
<div class="menu">

<input type="checkbox" id="wrap" name="wrap" value="Wrap" style="vertical-align: middle;">
<label for="wrap"> Wrap text</label>

<span class="material-symbols-outlined">wrap_text</span>
<span class="material-symbols-outlined">undo</span>
<span class="material-symbols-outlined">redo</span>
<span class="material-symbols-outlined">save</span>

</div>


<textarea  wrap="hard" class="input">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</textarea>

<script>
$("#wrap").change(function() {
    if(this.checked) {
        $(".input").css("width", "100%");
    }
else
{
$(".input").css("width", "1000%");
}
});
</script>
</body>

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

0

You can add event listener for the icons rather using checkbox as a selector.

 <span class="material-symbols-outlined" id="wrapText">wrap_text</span>

 let wrapText = $("#wrapText");

      wrapText.on("click", function () {
        $(".input").css("width", "100%");
      });
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