I have to implement a strange requirement that goes as follows:
- Users can hover on a link and get a descriptive text like "some text here"
- Users can click on the very same link and get a completely different text that might also contain markup (Example : some other text here)
I have looked at some jQuery plugins but most of them work with onhover OR onclick but not both. Also they seem to be using the "title" attribute for their content.
So my question is: is this functionality possible? Is there a jquery tooltip plugin where I can define different content for onhover and onclick events? Is there another way to achieve this? (Javascript is not one of my strong points).
I am also open to suggestions for simple standalone javascript libraries but it would be best if they are jQuery plugins.
Thank you.
Answer:
With the help of simpletip
Html code
<p>Hello <a id="test" title="some text here">world</a&g开发者_JAVA百科t; again</p>
and javascript
$("#test").simpletip({
persistent: true,
content: '<b>Some</b> other <i>text</i> here.'
});
How about you use jQuery plugin to display fancy tooltip onclick, and a title attribute for standard text (onhover)?
You could attach text to each element using the .data() jquery and then display that. It could even hold both the click and hover text in different data objects as you can attach complex objects.
精彩评论