Easy Tooltip content change via Javascript

不打扰是莪最后的温柔 提交于 2020-03-05 06:22:21

问题


Can you help me with changing the content of Easy Tooltip dynamically via Javascript? I tried almost everything:

document.getElementById('easy_tooltip').innerHTML(tooltipContent);
$("#easy_tooltip").html(tooltipContent);
$("#easy_tooltip").content(tooltipContent);

But it doesn't work. I cannot access the content of that element.

The example can be found here.

Thank you.


回答1:


The way this plugin is built is to use the title attribute of your element, so you can rather update your HTML code like this :

<a href="#" id="tooltip-1" class="tooltip" title="Tooltip 1">Tooltip 1</a>
<br />
<a href="#" id="tooltip-2" class="tooltip" title="Tooltip 2">Tooltip 2</a>

(See this fiddle)

And if you need a dynamic content, you can always modify this attribute with jQuery :

$("#tooltip-1").attr("title", "mycontent");


来源:https://stackoverflow.com/questions/13602853/easy-tooltip-content-change-via-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!