【发布时间】:2020-09-16 10:50:05
【问题描述】:
我正在设置一个解剖比较页面,其中我有两个并排的两个动物(例如泥小狗和鲨鱼)的插图,每个插图上都覆盖了一个 svg,以便单击肌肉会触发带有肌肉名称的工具提示它。
但是,我希望能够单击泥小狗上的“颌间肌”,并同时弹出泥小狗和鲨鱼的“颌间肌”工具提示。
如何使用 Tooltipster 实现这一目标?我正在考虑使用 functionReady 函数,但因为我是编程新手,所以我不知道如何使用它。
这是我现在的代码的 sn-p(请注意实际文件中有更多的 svg,我只是将它们取出,以便代码更易于阅读):
$(document).ready(function() {
$('.tooltip').tooltipster({
theme: ['tooltipster-shadow', 'tooltipster-shadow-customized'],
trigger: 'click'
});
});
<!-- Left column -->
<div class='diagram' style="width:calc(50% - 49px); float:left; height: 85%; background-image: url(Images/mudpuppy_sideview.png); background-repeat: no-repeat; background-size:contain;" id="leftCol">
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 792 612" style="enable-background:new 0 0 792 612;" xml:space="preserve">
<style type="text/css">
.tooltip{opacity:0;fill:#FFFFFF;}
</style>
<path id="mud_intermandibularis" class="tooltip" title="Intermandibularis" d=" M185.78,232.53c-3.77-6.28-32.12,3.11-42.47,5.87c-10.36,2.76-39.02,8.98-41.44,14.5
c-1.78,4.07,43.88,31.14,67.86,31.42c8.58,0.1,11.4-8.12,12.78-17.61C183.19,261.95,190.96,241.16,185.78,232.53z"/>
</svg>
</div>
<!-- Right column -->
<div class="diagram" style="width:calc(50% - 49px); float:right; height: 85%; background-image: url(Images/shark_sideview.png); background-repeat: no-repeat; background-size:contain;">
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 792 612" style="enable-background:new 0 0 792 612;" xml:space="preserve">
<style type="text/css">
.tooltip{opacity:0;fill:#FFFFFF;}
</style>
<path id="shark_intermandibularis" class="tooltip" title="Intermandibularis" d="M248.8,325.07c0,0-4.14,4.92-10.36,5.96c-6.22,1.04-18.39,0-18.39,0
s8.55,13.47,22.01,15.28c13.47,1.81,49.73-2.59,50.24-6.47S251.39,325.33,248.8,325.07z"/>
</svg>
</div>
任何帮助将不胜感激!谢谢!
【问题讨论】:
标签: javascript html tooltipster