Tôi đang sử dụng một flowplayer jquery cụ cắm http://flowplayer.org/tools/tooltip.htmlLiên kết/hủy liên kết đối tượng jquery để một yếu tố
1) Tôi muốn có một tooltip được tạo ra khi người dùng nhấp vào một phần tử.
2) Khi người dùng nhấp vào một yếu tố khác, các tooltip cũ phải được bỏ liên kết (xóa)
3) Một tooltip mới nên được tạo ra (hoặc cũ chuyển sang) cho các phần tử nhấp
4) Vì vậy, cần có < = 1 chú giải công cụ trên trang
Bạn có thể giúp tôi được không?
Dưới đây là đoạn code, nó chạy độc lập
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title>jQuery tooltip</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://cdn.jquerytools.org/1.1.2/full/jquery.tools.min.js"></script>
<script type="text/javascript">
/******* THIS FUNCTION IS JUST FOR TEST, REMOVE IT LATER *********/
$(document).ready(function() {
$("#_2").tooltip({
effect: "slide",
tip: '.tooltip' ,
position: 'bottom center'
});
});
/******* THIS FUNCTION IS JUST FOR TEST, REMOVE IT LATER *********/
/** The code below is not working as I expect, it doesn't MOVE tooltip **/
var old_id;
//first time - create tooltip
function my_create(id){
$("#"+id).tooltip({
effect: "slide",
tip: '.tooltip',
position: 'bottom center'
});
}
//next times - move tooltip to other element
function my_unlink(id){
$("#"+id).unbind("mouseover");
//todo
}
function my_link(id){
//todo
}
//THE MAIN FUNCTION
function do_tip(new_id){
if(old_id){
my_unlink(old_id);
my_link(new_id);
alert(new_id);
}
else
my_create(new_id);
old_id=new_id;
//new_id.focus();
}
</script>
<style>
.tooltip {
display: none;
background:transparent url(http://flowplayer.org/tools/img/tooltip/black_arrow_bottom.png);
font-size:14px;
height:70px;
width:160px;
padding:25px;
color:#fff;
}
h1 {
width: 400px;
text-align: center;
background-color: yellow;
}
</style>
</head>
<body>
<h1 onclick="do_tip(this.id)" id="_1">John</h1>
<h1 onclick="do_tip(this.id)" id="_2">Mary</h1>
<h1 onclick="do_tip(this.id)" id="_3">Dan</h1>
<h1 onclick="do_tip(this.id)" id="_4">Paul</h1>
<h1 onclick="do_tip(this.id)" id="_5">Kim</h1>
<div class="tooltip">There should be only one tooltip on a page!</div>
</body></html>
Có cuộc gọi đến tooltip() trả về bất cứ điều gì? Có một đối tượng đại diện cho tooptip mà có thể có một loại bỏ hoặc xóa phương pháp? – ironfroggy
1) gọi tới tooltip() trả về đối tượng jquery và nó cũng có thể trả về API dành riêng cho thư viện. 2) Không, không có hàm delete() hủy trong thư viện = ( – Dan