문제

<path xmlns="http://www.w3.org/2000/svg" d="M477.63,166.84l0.51,0.9l0.33,0.14l0.9,-0.21l1.91,0.47l3.68,0.16l0.17,-0.05l1.2,-0.75l2.78,-0.67l1.72,1.05l1.02,0.24l-0.97,0.97l-0.91,2.17l0.0,0.24l0.56,1.19l-1.58,-0.3l-0.16,0.01l-2.55,0.95l-0.2,0.28l-0.02,1.23l-1.92,0.24l-1.68,-0.99l-0.27,-0.02l-1.94,0.8l-1.52,-0.07l-0.15,-1.72l-0.12,-0.21l-0.99,-0.76l0.18,-0.18l0.02,-0.39l-0.17,-0.22l0.33,-0.75l0.91,-0.91l0.01,-0.42l-1.16,-1.25l-0.18,-0.89l0.24,-0.27Z" 
    data-code="BG" 
    fill="#cecdcd" 
    fill-opacity="1" 
    stroke="none" 
    stroke-width="0" 
    stroke-opacity="1" 
    fill-rule="evenodd" 
    id="test" 
    title="this as tool-tip" 
    class="jvectormap-region jvectormap-element"/>

I need that title attribute value as tool tip. I tried with the below but nothing happened.

$("path", svgRoot).mouseover(function() {
    //var content = $(this).attr("title");
    var id = $(this).attr("id");
    if (id != undefined) {
        $(this).tooltip();
    }
});
도움이 되었습니까?

해결책

In SVG a tooltip is not represented by a title attribute, you need a <title> child element instead.

I.e. while an HTML tooltip looks like this:

<p title="title">This is a paragraph.</p>

an SVG tooltip would look like this:

<text y="50"><title>This is the tooltip</title>This is some text<text>

or in your case

<path xmlns="http://www.w3.org/2000/svg" d="M477.63,166.84l0.51,0.9l0.33,0.14l0.9,-0.21l1.91,0.47l3.68,0.16l0.17,-0.05l1.2,-0.75l2.78,-0.67l1.72,1.05l1.02,0.24l-0.97,0.97l-0.91,2.17l0.0,0.24l0.56,1.19l-1.58,-0.3l-0.16,0.01l-2.55,0.95l-0.2,0.28l-0.02,1.23l-1.92,0.24l-1.68,-0.99l-0.27,-0.02l-1.94,0.8l-1.52,-0.07l-0.15,-1.72l-0.12,-0.21l-0.99,-0.76l0.18,-0.18l0.02,-0.39l-0.17,-0.22l0.33,-0.75l0.91,-0.91l0.01,-0.42l-1.16,-1.25l-0.18,-0.89l0.24,-0.27Z" 
    data-code="BG" 
    fill="#cecdcd" 
    fill-opacity="1" 
    stroke="none" 
    stroke-width="0" 
    stroke-opacity="1" 
    fill-rule="evenodd" 
    id="test" 
    class="jvectormap-region jvectormap-element">
    <title>this as tool-tip</title>
</path>

You don't need jquery and it won't work for SVG tooltips anyway.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top