I'm very new to SVG, so please forgive me if this is a basic question.
I would like to draw circles on the screen and respond whenever the user mouses over each circle.
From what I can tell, when listening to mouse events on an svg, we are actually listening to mouse events on the whole canvas and not on the shapes.
If I want to handle events on the shapes, I have to use a library like D3.
Is it possible to listen to mouseOver event that are triggered when the mouse pointer passes over a specific circle?
Try this...
No library is needed for this. Given the following SVG:
You could use CSS or Javascript to have these circles change in some way related to the mouse.
For a simple hover in css you can do something like:
Or any JavaScript mouse event like so:
Here is a demo for you to check out: http://codepen.io/ZevanRosser/pen/bdYyLp
If you want this to only be svg and be able to open this in a browser and see the effect (although Zevan's answer can be embedded in svg), use something like:
the CSS option shared is cleaner, but this pattern may offer more flexibility for future mouse handling, especially if needing a function to figure out how long you want to let a user "pause" over the circle before actually modifying the property.