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

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 this?

<svg>
  <image /> 
</svg>
    
asked by anonymous 28.08.2015 / 16:41

3 answers

3

HTML

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

CSS

.element:hover{
    cursor:pointer;
}
    
28.08.2015 / 16:51
0

Add the onmouseover event available in SVG components

SVG

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

CSS

 #svg-image:hover { cursor: pointer }
    
28.08.2015 / 17:08
-2

By using 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");
        }
    );
});
    
28.08.2015 / 16:54