0

I have a list of items displayed in a grid on the screen. As I hover the mouse over the items, I'd like to show a specific tooltip for each item. How can I accomplish that using javascript, jquery or angular js, please? Thanks.

1

2 Answers 2

0

You can use angular ui tooltip.

$scope.titles = [
    {
      "id" : 1,
      "title" : "title1",
      "tooltip" : "tip1"
    }, 
    {
      "id" : 2,
      "title" : "title2",
      "tooltip" : "tip2"
    }, 
    {
      "id" : 3,
      "title" : "title3",
      "tooltip" : "tip3"
    }, 
    {
      "id" : 4,
      "title" : "title4",
      "tooltip" : "tip4"
    }, 


  ]

in HTML

<p ng-repeat = "x in titles" tooltip-placement="top-left" uib-tooltip="{{x.tooltip}}">{{x.title}}</p>

Have a look at plunker

Sign up to request clarification or add additional context in comments.

Comments

0

You could just add the html attribute "title" to the items. As example, lets say your items is an ordered list. just do it like this:

<ol>
   <li title='this is item number one'>Item One</li>
   <li title='this is the second items'>Item Two</li>
   <li title='third!'>Item Three</li>
</ol>

For more fancy tooltip, you could just use CSS. Or for me, I usually use Bootstrap for my project, so I just use Bootstrap Tooltip which is:

<li data-toggle="tooltip" title="This is item no 1!">Item One</li>

1 Comment

I forgot to mention that the "value" of the tooltip can't be coded in the html. the list is retrieved from a database, depending on the search criteria provided by the user. the tooltip will depend on some information in each line, that is, I'll have an attribute in the line that will determine the value of the tooltip. thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.