views:

104

answers:

2

I want to create a tool tip for an image with a link now I had it working one but it doesn't work with the 2nd image.

Here is my Sample Code:

<!-- 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>

and here is my script that makes it all happens:

<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>

but not working please help. here is the sample Jquery I am trying todo

+1  A: 
 $("#test2").tooltip({ // You had .tooltip2
 effect: 'slide',
    offset: [50, 40] }); 
});

Explanation:

The tooltip plugin provides a function called tooltip that is part of the jQuery object. Once you load jquery and the tooltip plugin, every jquery object you create [FYI: $(selector) creates a jquery object] can call that function on itself.

When you call tooltip2() you are calling a function that does not exist, and so nothing happens.

Does that make sense?

Sean Vieira
I don't get it.. sorry im new to this jquery stuff
kwek-kwek
@kwek-kwek ... updated my answer -- let me know if you need / would like more.
Sean Vieira
that work thanks
kwek-kwek
I'm not that familiar with the tooltip plugin -- how does it know which div to move? It looks like it will always use the first div.
Kathy Van Stone
@Kathy; `tooltip` is called on the element or set of elements you want to turn into a tooltip, rather than on the element you want to turn into a tooltip. To quote http://docs.jquery.com/Plugins/Tooltip : `The content of a tooltip is by default the title of the element, with the href or src attribute below it, if present.`
Sean Vieira
A: 

I would try this for the 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>

and this for the 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>
kayos
didn't work and plus #test2 has a different information to be shown
kwek-kwek