我使用.placeTaken类将tipsy工具提示添加到div。然后,用户可以拖动框,因此我删除了该类,并将其添加到新的div中。当发生这种情况时,我向该div添加了一个新的tipsy工具提示,它工作得很好,但我想删除旧的提示。
他们说,如果您希望通过将title属性设置为空字符串来删除工具提示,请改为设置original-title属性。我尝试过$("#"+dropFromId).attr("original-title", "");,但工具提示仍然在那里。我甚至不能通过设置另一个原始标题来更改工具提示标题。
我做错了什么?
编辑:我想我没有给你们足够的信息。我使用ajax从数据库中获取位置。PHP返回一个关联数组(customers),然后我在JavaScript中使用该数组,其中发生的地方与一个名称相匹配。删除时,被占用的位置会发生变化,因此我再次执行ajax函数,用所有被占用的位置更新数组。首先,我将tipsy工具提示添加到所有拍摄的位置,如下所示
$("#map div.placeTaken").tipsy({gravity: 'w', html: true, fade: true, title:
function(){
// id could for example be map74, substring to 74
var id = $(this).attr("id").substring(3,6);
return '<div>'+customers[id]+'</div><br />';
}
});因此,标题等于与数组中的位置相匹配的内容。我希望我的解释已经足够好了。当盒子被放到一个新的地方时,会发生这样的事情
$("#map div span").bind( "dragstop", function(event, ui) {
// some code here to change the .placeTaken class
// update database with the new place
$.ajax({
type: "POST",
url: "map.php",
data: "dropFromId="+ dropFromId.substring(3,6) +"& dropToId="+ dropToId.substring(3,6),
success: function(){
// ajax function to update the js array with new places
customerTooltip();
}
});
// on this place, add tooltip
$("#"+dropToId).tipsy({gravity: 'w', html: true, fade: true, title:
// funktion för att avgöra vilken title som ska användas
function(){
var id = dropToId.substring(3,6);
return '<div>'+customers[id]+'</div><br />';
}
});
}
});这一切都很好,所以我想我可以简单地将dropFromId标题更改为"“,这样我就可以删除它。
发布于 2011-02-01 12:14:25
使用$(".tipsy").remove();似乎可以做到这一点,因为当工具提示显示时,带有tipsy类的div被附加到文档的主体。
只需确保你没有在其他地方使用tipsy类(也就是说你的工具提示类似于toolTip )
发布于 2012-10-26 10:23:47
最简单的解除醉酒的方法;
$('.tipsy:last').remove();发布于 2012-11-07 15:07:08
如果您不想再显示tipsy,只需在元素上使用.tipsy('disable')即可。
如果你正在使用trigger: manual并且你想隐藏它,你只需要移除body上的.tipsy div即可。
还有disable enable和toggleEnabled
https://stackoverflow.com/questions/3449321
复制相似问题