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

201
Views
Adding an onClick event to an svg element in a java script class

I'm trying to add an onClick event to an svg tag where i want it to direct me to another page which is page2.html. I really tried everything but I couldn't find a solution. If there is another way of doing that other than using onClick would be great as well3 Would really appreciate the help. Here is my code:-

import React from "react";
import "./HeaderBox.css";
import "./HeaderBox.scss";
import { Card } from "react-bootstrap";

const HeaderBox = () => {
  return (
    <Card id="Header">
      <button>page</button>
      <div class="HeaderDiv">Omar Fares</div>
      <svg viewBox="45 60 400 320" xmlns="http://www.w3.org/2000/svg">
        <path
          fill="#fff"
          d="M 90 210 C 90 180 90 150 90 150 C 150 150 180 150 180 150 C 180 150 300 150 300 150 C 300 150 330 150 390 150 C 390 150 390 180 390 210 C 390 240 390 270 390 270 C 330 270 300 270 300 270 C 300 270 180 270 180 270 C 180 270 150 270 90 270 C 90 270 90 240 90 210"
          mask="url(#knockout-text)"
        ></path>
        <mask id="knockout-text">
          <rect width="100%" height="100%" fill="#fff" x="0" y="0" />
          <text x="147" y="227" fill="#000">
            Memory
          </text>
        </mask>
        <a onClick="window.location.href='page2.html'"></a>
      </svg>
      
    </Card>
  );
};
export default HeaderBox;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In React, you need to assign a function to onClick

 onClick={() => window.location.href='page2.html'}
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!