开发者

jQuery advanced tooltip with different onhover and onclick content

I have to implement a strange requirement that goes as follows:

  1. Users can hover on a link and get a descriptive text like "some text here"
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜