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

117
Views
How to use an event on svg?

I'm trying to start a simple animation on an svg element in HTML, but the effect doesn't work.

I want to add this:

.arrow-behind {
 -webkit-transform: translateY(-15px);
         transform: translateY(-15px);
}

.arrow-front {
  -webkit-transform: translateY(15px);
         transform: translateY(15px);
 }

to this,

HTML:

   <div class="content">
      <p>Hover me !</p>
      <svg id="more-arrows">
        <polygon  points="37.6,64 0,36.1 5.1,32.8 37.6,56.8 70.4,32.8 75.5,36.1 "/>
        <polygon  points="37.6,64 0,36.1 5.1,32.8 37.6,56.8 70.4,32.8 75.5,36.1 "/>
      </svg>
    </div>

CSS:

#more-arrows {
  width: 75px;
  height: 85px;
}

 #more-arrows polygon {
  fill: #FFF;
  -webkit-transition: all .2s ease-out;
  transition: all .2s ease-out;
}

with this,

JS:

clicked = document.getElementById("more-arrows");

clicked.addEventListener("click", opened)

function opened() {
  addclass = document.getElementsByClassName("polygon")
  addclass.setAttribute("class", "arrow-behind");
  addclass.setAttribute("class", "arrow-front");
}
about 4 years ago · Juan Pablo Isaza
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!