如何在jquery中创建超链接

时间:2014-07-02 05:54:17

标签: jquery hyperlink

以下是在附加图片上创建黑色文字的代码..

这是在jquery中完成的绘图。我需要使这些圈子超链接(在图像中)。只要点击这些圈子,它就会打开另一个标签。任何想法怎么做?

function oncanvasmousemove(evt) {
    clearTimeout(timer);
    lastTimeMouseMoved = new Date().getTime();
    timer = setTimeout(function () {
        var currentTime = new Date().getTime();
        if (currentTime - lastTimeMouseMoved > 300) {
            var mousePos = getMousePos(canvas, evt);
            var tC, isMatched = false;
            for (c = 0; c < circles.length; c++) {
                tC = circles[c];
                if (mousePos.DistanceTo(tC.centerX, tC.centerY) < tC.Radius + 5) {
                    isMatched = true;
                    break;
                }
            }
            if (isMatched === true) {
                $("#tooltip").html(tC.Text).css({
                    'top': mousePos.Y + canvasoffset.top - 40,
                        'left': mousePos.X + canvasoffset.left - $("#tooltip").width() / 2
                }).show();
            } else {
                $("#tooltip").click(function () {
                    alert("The paragraph was clicked.");
                });
            }
        }
    }, 300);
}

1 个答案:

答案 0 :(得分:0)

我们可以利用地图和区域标签将多个超链接链接到特定坐标的图像。

通过使用这些标签,我们可以根据坐标将更多超链接附加到单个图像。

以下是示例代码:

<!DOCTYPE html>
<html>
<body>

<p>Click on the sun or on one of the planets to watch it closer:</p>

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
  <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>

</body>
</html> 

Source

希望这会对你有所帮助。

相关问题