[英]HTML/JavaScript Tooltips on buttons in a Colorbox lightbox
將HTML / JavaScript工具提示附加到Colorbox燈箱中的cboxPrevious
和cboxNext
按鈕的最簡單方法是什么?
為了顯示到目前為止我已經嘗試了什么,這里是從Colorbox主頁獲取的簡化的colorbox演示:
<html>
<head>
<title>Colorbox Example</title>
<base href="http://www.jacklmoore.com/colorbox/example1/">
<link rel="stylesheet" href="colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
//Examples of how to assign the Colorbox event to elements
$(".group1").colorbox({rel:'group1', current: 'hallo'.link("http://google.com") });
});
</script>
</head>
<body>
<h1>Colorbox Demonstration</h1>
<p><a class="group1" href="../content/ohoopee1.jpg" title="Me and my grandfather on the Ohoopee.">Grouped Photo 1</a></p>
<p><a class="group1" href="../content/ohoopee2.jpg" title="On the Ohoopee as a child">Grouped Photo 2</a></p>
<p><a class="group1" href="../content/ohoopee3.jpg" title="On the Ohoopee as an adult">Grouped Photo 3</a></p>
</body>
</html>
當您在瀏覽器中打開此頁面並單擊第一個鏈接時,您將獲得一個帶有箭頭的顏色框,用於顯示上一張和下一張圖像。 我想在這些按鈕上附加工具提示。
我知道如何在HTML中附加工具提示。 只需添加一個title屬性:
<span title="Tooltip text">Some text</span>
因此,我在JavaScript中進行了類似的嘗試,首先針對cbxCurrent
文本:我修改了該行
$(".group1").colorbox(...
這樣它顯示為:
$(".group1").colorbox({rel:'group1', current: '<span title="Tooltip text">Some text</span>' });
這可行! 但是,當我嘗試使用上previous
按鈕時,它什么也沒做:
$(".group1").colorbox({rel:'group1', previous: '<span title="Tooltip text">Some text</span>' });
我想我必須將title屬性附加到cboxPrevious
背景圖像上(因為使用的CSS文件顯示背景圖像包含箭頭,而文本被縮進了隱形狀態),但是我不知道如何在此附加工具提示JavaScript函數中的元素。
$('MY_ID').colorBox({ onOpen: function() { $("#tt").tooltip("disable"); }, onClosed: function() { $("#tt").tooltip("enable"); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.