我用.placeTaken類爲div添加醉意的工具提示。用戶然後可以拖動框,所以我刪除類並將其添加到一個新的div。發生這種情況時,我爲該div添加了一個新的提示性工具提示,並且工作正常,但我想刪除舊的提示。jQuery:如何刪除醉tool tool的工具提示?
他們說,如果您希望通過將title屬性設置爲空字符串來刪除工具提示,請改爲設置original-title屬性。我試過$("#"+dropFromId).attr("original-title", "");
,但工具提示仍然存在。我甚至不能通過設置另一個原始標題來更改工具提示標題。
我在做什麼錯?
編輯:我想我沒有給你們足夠的信息。我使用ajax來抓取從數據庫中取出的地方。 PHP返回一個關聯數組(客戶),然後在我的JavaScript中使用,其中發生的地方與名稱匹配。刪除時所採用的位置發生更改,所以我再次執行ajax函數以更新所有已採用位置的數組。在拳頭,我醉意工具提示添加到所有拍攝的地方,像這樣
$("#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標題爲「」的下降,讓我將其刪除。
你能提供一些示例代碼,顯示問題? – 2010-08-10 13:27:22
你應該發佈你的html,因爲tooltip來自'title'屬性,除非你使用了一些自定義屬性。 – Sarfraz 2010-08-10 13:29:45
好的,我發佈了一些代碼。 – Charles 2010-08-10 14:02:20