Tooltips not showing when hovering over SVG polygo

2019-01-27 12:53发布

问题:

I have an SVG map of Colorado with polygons for each county. I'd like the county name to pop up on mouse hover, but that isn't happening. I have the counties set to change fill on hover, too, and that is happening. I'm not sure what the difference is.

These are just standard browser tooltips, with the intended text set in each polygon's title attribute.

Fiddle here: http://jsfiddle.net/mmparker/sVbxT/4/

回答1:

For SVG you need to use a nested <title> element rather than a title attribute. E.g. <polygon points="..."><title>your title</title></polygon>



标签: html svg tooltip