Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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 UI时遇到问题-提示-图像_Jquery_Html_Jquery Ui - Fatal编程技术网

使用Jquery UI时遇到问题-提示-图像

使用Jquery UI时遇到问题-提示-图像,jquery,html,jquery-ui,Jquery,Html,Jquery Ui,我正在尝试创建一个显示图像而不是文本的悬停工具提示,下面是我的代码: $(document).ready(function () { $(".tips").tooltip({ content: function () { return '<img src="' + $(this).attr("href") + '" />' } }); }); $(文档).ready(函数(){ $(“.tips”)。工具提示(

我正在尝试创建一个显示图像而不是文本的悬停工具提示,下面是我的代码:

$(document).ready(function () {
    $(".tips").tooltip({
        content: function () {
            return '<img src="' + $(this).attr("href") + '" />'
        }
    });
});
$(文档).ready(函数(){
$(“.tips”)。工具提示({
内容:功能(){
返回“”
}
});
});
对于此Html

<a href="http://materialmix.com/uploads/5e9667aa-3537-4c41-8d01-520447285b76_r.jpg" class="tips">
                                            <img src="http://plastic.jasonscms.com//images/camera.png">
                                        </a>

我创作了一把小提琴:

有人能看出我做错了什么吗?它现在什么都不做,也不会出错。

您只需要向元素添加带有任意值的“title”属性,就可以使工具提示正常工作

<a title="default tooltip" href="http://materialmix.com/uploads/5e9667aa-3537-4c41-8d01-520447285b76_r.jpg" class="tips">
    <img src="http://plastic.jasonscms.com//images/camera.png" />
</a>

您只需向元素添加带有任意值的“title”属性,即可使工具提示正常工作

<a title="default tooltip" href="http://materialmix.com/uploads/5e9667aa-3537-4c41-8d01-520447285b76_r.jpg" class="tips">
    <img src="http://plastic.jasonscms.com//images/camera.png" />
</a>

您只需向元素添加带有任意值的“title”属性,即可使工具提示正常工作

<a title="default tooltip" href="http://materialmix.com/uploads/5e9667aa-3537-4c41-8d01-520447285b76_r.jpg" class="tips">
    <img src="http://plastic.jasonscms.com//images/camera.png" />
</a>

您只需向元素添加带有任意值的“title”属性,即可使工具提示正常工作

<a title="default tooltip" href="http://materialmix.com/uploads/5e9667aa-3537-4c41-8d01-520447285b76_r.jpg" class="tips">
    <img src="http://plastic.jasonscms.com//images/camera.png" />
</a>

您需要指定
items
参数,因为您没有使用默认的
title
属性。看

现在,您需要调整内容函数以查找父锚点:

$(".tips").tooltip({
    items: "img",
    content: function () {
        var element = $(this);
        var src = element.parent("a.tips").attr("href");
        console.log(src);
        return '<img src="' + src + '" class="tooltip-img" />'
    }
});

<style>
    .tooltip-img { height: 25px; width: 30px; }
</style>
$(“.tips”)。工具提示({
项目:“img”,
内容:功能(){
var元素=$(此);
var src=element.parent(“a.tips”).attr(“href”);
console.log(src);
返回“”
}
});
.tooltip img{高度:25px;宽度:30px;}

这是一个更新的。

您需要指定
items
参数,因为您没有使用默认的
title
属性。看

现在,您需要调整内容函数以查找父锚点:

$(".tips").tooltip({
    items: "img",
    content: function () {
        var element = $(this);
        var src = element.parent("a.tips").attr("href");
        console.log(src);
        return '<img src="' + src + '" class="tooltip-img" />'
    }
});

<style>
    .tooltip-img { height: 25px; width: 30px; }
</style>
$(“.tips”)。工具提示({
项目:“img”,
内容:功能(){
var元素=$(此);
var src=element.parent(“a.tips”).attr(“href”);
console.log(src);
返回“”
}
});
.tooltip img{高度:25px;宽度:30px;}

这是一个更新的。

您需要指定
items
参数,因为您没有使用默认的
title
属性。看

现在,您需要调整内容函数以查找父锚点:

$(".tips").tooltip({
    items: "img",
    content: function () {
        var element = $(this);
        var src = element.parent("a.tips").attr("href");
        console.log(src);
        return '<img src="' + src + '" class="tooltip-img" />'
    }
});

<style>
    .tooltip-img { height: 25px; width: 30px; }
</style>
$(“.tips”)。工具提示({
项目:“img”,
内容:功能(){
var元素=$(此);
var src=element.parent(“a.tips”).attr(“href”);
console.log(src);
返回“”
}
});
.tooltip img{高度:25px;宽度:30px;}

这是一个更新的。

您需要指定
items
参数,因为您没有使用默认的
title
属性。看

现在,您需要调整内容函数以查找父锚点:

$(".tips").tooltip({
    items: "img",
    content: function () {
        var element = $(this);
        var src = element.parent("a.tips").attr("href");
        console.log(src);
        return '<img src="' + src + '" class="tooltip-img" />'
    }
});

<style>
    .tooltip-img { height: 25px; width: 30px; }
</style>
$(“.tips”)。工具提示({
项目:“img”,
内容:功能(){
var元素=$(此);
var src=element.parent(“a.tips”).attr(“href”);
console.log(src);
返回“”
}
});
.tooltip img{高度:25px;宽度:30px;}

这是更新的。

将此标记为正确,因为它不需要额外标记。将此标记为正确,因为它不需要额外标记。将此标记为正确,因为它不需要额外标记。将此标记为正确,因为它不需要额外标记。谢谢您的回答!谢谢你的回答!谢谢你的回答!谢谢你的回答!