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

152
Visualizações
React How to add on hover border for <area> tag

Currently I have image map on that I am plotting Area

Ex.

<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
  <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  <area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>

once we hover the area how to add border around it.

following code works fine in Javascript but how can I do that in React.

How to put border on <area>?

var areas = document.getElementsByTagName( 'area' );
for( var index = 0; index < areas.length; index++ ) {    
    areas[index].addEventListener( 'mouseover', function () {this.focus();}, false );
    areas[index].addEventListener( 'mouseout', function () {this.blur();}, false );
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you can write your js codes before return. And here`s a example for you

import React, { useEffect } from "react";

export default function Header() {
  useEffect(() => {
    function myFunction() {
      var areas = document.getElementsByTagName("area");
      for (var index = 0; index < areas.length; index++) {
        areas[index].addEventListener(
          "mouseover",
          function () {
            this.focus();
          },
          false
        );
        areas[index].addEventListener(
          "mouseout",
          function () {
            this.blur();
          },
          false
        );
      }
    }
    myFunction();
  }, []);

  return (
    <div>
      <img
        alt="img"
        id="map"
        src="http://thinkingstiff.com/images/matt.jpg"
        usemap="#map"
      />
      <map name="map">
        <area alt="area" shape="circle" coords="50,50,50" href="#" />
        <area alt="area" shape="circle" coords="100,100,50" href="#" />
      </map>
    </div>
  );
}
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