【问题标题】:JQuery Tool tipsjQuery 工具提示
【发布时间】:2010-04-08 19:11:17
【问题描述】:

我想为带有链接的图像创建一个工具提示,现在我可以使用它,但它不适用于第二张图像。

这是我的示例代码:

<!-- trigger element. a regular workable link --> 
<a id="test" title="Name - Title">Name</a> 

<!-- tooltip element --> 
<div class="tooltip"> 
 <div><span class="name">Name</span><br />
Title
<span><a href="#">more info»</a></span></div>
</div>

<!-- trigger element. a regular workable link -->
<a id="test2" title="Name - Title">Name</a> 

<!-- tooltip element --> 
<div class="tooltip2"> 
 <div><span class="name">Name</span><br />
Title
<span><a href="#">more info»</a></span></div>
</div>

这是我的脚本,让这一切发生:

<script>
// What is $(document).ready ? See: http://flowplayer.org/tools/using.html#document_ready

$(document).ready(function() {

 // enable tooltip for "test" element. use the "slide" effect
 $("#test").tooltip({ 
 effect: 'slide',
    offset: [50, 40] }); 

 $("#test2").tooltip2({ 
 effect: 'slide',
    offset: [50, 40] }); 
});
</script>

但不工作请帮忙。这是我正在尝试做的sample Jquery

【问题讨论】:

  • 如果您包含 jquery-plugins 作为标签,您应该提及您正在使用的插件。

标签: jquery jquery-plugins tooltip


【解决方案1】:
 $("#test2").tooltip({ // You had .tooltip2
 effect: 'slide',
    offset: [50, 40] }); 
});

说明:

工具提示插件提供了一个名为tooltip 的函数,它是jQuery 对象的一部分。加载 jquery 和工具提示插件后,您创建的每个 jquery 对象 [仅供参考:$(selector) 创建一个 jquery 对象] 可以自行调用该函数。

当您调用 tooltip2() 时,您正在调用一个不存在的函数,因此没有任何反应。

这有意义吗?

【讨论】:

  • 我不明白.. 对不起,我是这个 jquery 的新手
  • @kwek-kwek ... 更新了我的答案——如果您需要/想要更多,请告诉我。
  • 我对工具提示插件不太熟悉——它怎么知道要移动哪个 div?看起来它总是会使用第一个 div。
  • @Kathy; tooltip 是在您想要变成工具提示的元素或元素集上调用的,而不是在您想要变成工具提示的元素上调用。引用docs.jquery.com/Plugins/TooltipThe content of a tooltip is by default the title of the element, with the href or src attribute below it, if present.
【解决方案2】:

我会为 html 尝试这个...

<!-- trigger element. a regular workable link --> 
<a id="test" title="Name - Title">Name</a> 

<!-- tooltip element --> 
<div class="tooltip"> 
 <div><span class="name">Name</span><br />
Title
<span><a href="#">more info»</a></span></div>
</div>

<!-- trigger element. a regular workable link -->
<a id="test2" title="Name - Title">Name</a> 

<!-- tooltip element --> 
<div class="tooltip"> 
 <div><span class="name">Name</span><br />
Title
<span><a href="#">more info»</a></span></div>
</div>

这用于 javascript...

<script>
// What is $(document).ready ? See: http://flowplayer.org/tools/using.html#document_ready

$(document).ready(function() {

 // enable tooltip for "test" element. use the "slide" effect
 $("#test, #test2").tooltip({ 
 effect: 'slide',
    offset: [50, 40] }); 
});
</script>

【讨论】:

  • 没有用,而且 #test2 有不同的信息要显示
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多