Tooltipster使用jQuery更改标题
好的,我成功地实现了Tooltipster,并创建了一个具有以下标题的图像:Tooltipster使用jQuery更改标题,jquery,tooltipster,Jquery,Tooltipster,好的,我成功地实现了Tooltipster,并创建了一个具有以下标题的图像: <img id="DeviceIvan" class="tooltipsterIvan" src="Slike/urSamsungS7.png" title="Some Tekst bla bla works great."/> 但这似乎不起作用 我还尝试: var image = document.querySelector('img'); image.title = 'Your title'; //
<img id="DeviceIvan" class="tooltipsterIvan" src="Slike/urSamsungS7.png"
title="Some Tekst bla bla works great."/>
但这似乎不起作用
我还尝试:
var image = document.querySelector('img');
image.title = 'Your title'; // Assigning directly to attribute.
image.setAttribute('title', 'Your other title'); // Assigning by method.
但这也不起作用。
有人能帮你用jQuery更改标题吗?你的问题很“小”…因为我看不出您是如何实现的,所以我在这里做得非常简单 现在,实例化Tooltipster后,要更改标题,您必须
销毁第一个实例,更改标题…
然后,重新实例化Tooltipster
我在示例中放置了一个按钮来执行此操作
// On load instantiation of Tooltipster.
$('#DeviceIvan').tooltipster({
theme: 'tooltipster-punk'
});
$("#test").on("click",function(){
// Destroy the first instance.
$('#DeviceIvan').tooltipster("destroy");
// change the title attribute and re-instantiate.
$('#DeviceIvan').attr("title","I have changed the text yo!!!").tooltipster({
theme: 'tooltipster-punk'
});
});
是的,这奏效了!非常感谢您@Louis Patrice Bessette
// On load instantiation of Tooltipster.
$('#DeviceIvan').tooltipster({
theme: 'tooltipster-punk'
});
$("#test").on("click",function(){
// Destroy the first instance.
$('#DeviceIvan').tooltipster("destroy");
// change the title attribute and re-instantiate.
$('#DeviceIvan').attr("title","I have changed the text yo!!!").tooltipster({
theme: 'tooltipster-punk'
});
});