從jQuery UI API繼工具提示教程我試圖創建自定義html內容的工具提示,但沒有顯示出來。控制檯顯示我的腳本沒有錯誤,只有一些來自jQuery-UI(但沒有特別的)。jQuery的自定義內容工具提示什麼都沒有
任何人都可以告訴我我做錯了什麼嗎?
$(document).ready(function() {
$(function() {
$(document).tooltip({
items: "custom-tooltip",
content: function() {
var element = $(this);
if (element.is("custom-tooltip")) {
return "<a>THIS<br/>IS<br/><A><br/>TOOLTIP!";
}
}
});
});
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CUSTOM TOOLTIPS</title>
<link rel="stylesheet" href="jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jquery-1.10.2.js"></script>
<script src="jquery-ui.js"></script>
<script src="tooltips.js"></script>
</head>
<body>
<h3><a href="#" custom-tooltip="">HOVER ME</a></h3>
</body>
</html>
嗯,這就是我想要它的情況下,使用簡單的東西時,如果我想在多個元素上使用多個工具提示,或者有更簡單的方法,那麼IF是否適用?就像我對5個不同元素有5個不同的工具提示一樣,我會爲每個元素做出判斷,如果是句子 – 2015-03-19 11:28:06
傳統的方式是使用「title」。但是,如果你動態地加載內容,你擁有的是一個很好的簡單的方法。 [jqueryui頁面上的一個例子](https://jqueryui.com/tooltip/#custom-content)也一樣 – blgt 2015-03-19 11:32:47