Move the mouse, and know that I’m on top of an object

Asked

Viewed 80 times

0

I have an image in SVG and when I have the mouse over the image make an Alert and change the cursor to the hyperlink cursor. How can I do that?

<svg>
  <image /> 
</svg>

3 answers

3

HTML

<svg class="element">
  <image /> 
</svg>

CSS

.element:hover{
    cursor:pointer;
}

0

Add the event onmouseover available in SVG components

SVG

<svg>
  <image onmouseover="alert('Isso é um alert');"/> 
</svg>

CSS

 #svg-image:hover { cursor: pointer }

-2

Through the use of jQuery, you have the onHover function. Basically you have to do:

$(document).ready(function(){
    $("image").hover(function(){
        $(this).css( 'cursor', 'pointer' );
        console.log("Estou em cima da imagem");
        }
    );
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.