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

113
Views
removeClass on element arrow with using jquery

There is a table with headings and heading arrows (down / up).

<th><div>
<div class='column-name'>Col1</div>
<div class='arrows'>
<div class="i-con-arrow-down"></div>
<div class="i-con-arrow-up"></div>
</div>
</div></th>
<th><div>
<div class='column-name'>Col2</div>
<div class='arrows'>
<div class="i-con-arrow-down"></div>
<div class="i-con-arrow-up"></div>
</div>
</div></th>
<th><div>
<div class='column-name'>Col3</div>
<div class='arrows'>
<div class="i-con-arrow-down"></div>
<div class="i-con-arrow-up"></div>
</div>
</div></th>

I want the class to be added when I click on the arrow, and to delete it in other arrows. I wrote such a handler for a click (for the down arrow), how can I make sure that the class is deleted from all other arrows?Thanks.Broke through different comments of parent and siblings, but there is no effect.

$('body').on('click', '.i-con-arrow-down', function() {
$(this).addClass('text-primary').siblings().removeClass('text-primary');
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I correctly understand you question, that should be a working code.

$('body').on('click', '.i-con-arrow-down, .i-con-arrow-up', function() {
  $('.text-primary').removeClass('text-primary');
  $(this).addClass('text-primary');
});
.i-con-arrow-down, .i-con-arrow-up {
  background: black;
  padding:20px;
  margin: 20px;
 }
.text-primary {
  background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<th><div>
  <div class='column-name'>Col1</div>
  <div class='arrows'>
    <div class="i-con-arrow-down"></div>
    <div class="i-con-arrow-up"></div>
  </div>
  </div></th>
<th><div>
  <div class='column-name'>Col2</div>
  <div class='arrows'>
    <div class="i-con-arrow-down"></div>
    <div class="i-con-arrow-up"></div>
  </div>
</div></th>
<th><div>
  <div class='column-name'>Col3</div>
  <div class='arrows'>
    <div class="i-con-arrow-down"></div>
    <div class="i-con-arrow-up"></div>
  </div>
</div></th>

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!