Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery:如何在SVG';他和fancybox在一起?_Jquery_Svg_Hyperlink_Fancybox - Fatal编程技术网

jQuery:如何在SVG';他和fancybox在一起?

jQuery:如何在SVG';他和fancybox在一起?,jquery,svg,hyperlink,fancybox,Jquery,Svg,Hyperlink,Fancybox,我在每个SVG元素周围都有一个链接,当我点击一个链接时,我希望在fancybox的帮助下弹出一个图像。到目前为止,这张图片只是在一个新网站上弹出,而不是通过fancybox。在我添加SVG元素之前,一切都很顺利。有什么建议吗 我试过这样的方法: <a class="fancybox" title="RAM" xlink:href="http://www.studioinfotronic.it/images/Memory-Module-icon.png" target="_blank">

我在每个SVG元素周围都有一个链接,当我点击一个链接时,我希望在fancybox的帮助下弹出一个图像。到目前为止,这张图片只是在一个新网站上弹出,而不是通过fancybox。在我添加SVG元素之前,一切都很顺利。有什么建议吗

我试过这样的方法:

<a class="fancybox" title="RAM" xlink:href="http://www.studioinfotronic.it/images/Memory-Module-icon.png" target="_blank"><polygon points="142.961,71.376 117.479,174.914 117.479,186.584 268.354,186.618 278.195,83.04 278.195,71.376"/></a>


似乎fancybox在从svg的链接获取内容时遇到了问题(
xlink:href

作为一种解决方法,我将使用
.each()
方法手动构建库,如:

var gallery = [];
$(".fancybox").each(function (i) {
    gallery[i] = {
        href: $(this).attr("xlink:href"),
        title: $(this).attr("title")
    };
    $(this).on("click", function () {
        $.fancybox(gallery, {
            index: i,
            helpers: {
                title: {
                    type: 'inside',
                    position: 'top',
                }
            },
            openSpeed: 'slow',
            closeSpeed: 'slow',
            autoDimensions: true
        });
        return false;
    }); // on
}); // each
见分叉