Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!